Merge branch 'cmake_fixes' into 'master'

Formatting and coverage related CMake files fixes

See merge request OpenMW/openmw!2811
depth-refraction
psi29a 2 years ago
commit efebb8efd8

@ -132,6 +132,7 @@ Clang_Format:
before_script: before_script:
- CI/install_debian_deps.sh openmw-clang-format - CI/install_debian_deps.sh openmw-clang-format
script: script:
- CI/check_cmake_format.sh
- CI/check_file_names.sh - CI/check_file_names.sh
- CI/check_clang_format.sh - CI/check_clang_format.sh

@ -0,0 +1,6 @@
#!/bin/bash -ex
git ls-files -- ':(exclude)extern/' 'CMakeLists.txt' '*.cmake' |
xargs grep -P '^\s*\t' &&
( echo 'CMake files contain leading tab character. Use only spaces for indentation'; exit -1 )
exit 0

@ -58,9 +58,9 @@ option(BUILD_BULLETOBJECTTOOL "Build Bullet object tool" ON)
set(OpenGL_GL_PREFERENCE LEGACY) # Use LEGACY as we use GL2; GLNVD is for GL3 and up. set(OpenGL_GL_PREFERENCE LEGACY) # Use LEGACY as we use GL2; GLNVD is for GL3 and up.
if (NOT BUILD_LAUNCHER AND NOT BUILD_OPENCS AND NOT BUILD_WIZARD) if (NOT BUILD_LAUNCHER AND NOT BUILD_OPENCS AND NOT BUILD_WIZARD)
set(USE_QT FALSE) set(USE_QT FALSE)
else() else()
set(USE_QT TRUE) set(USE_QT TRUE)
endif() endif()
# If the user doesn't supply a CMAKE_BUILD_TYPE via command line, choose one for them. # If the user doesn't supply a CMAKE_BUILD_TYPE via command line, choose one for them.
@ -227,7 +227,7 @@ if (WIN32)
endif() endif()
if(MSVC) if(MSVC)
add_compile_options("/utf-8") add_compile_options("/utf-8")
endif() endif()
# Dependencies # Dependencies
@ -237,10 +237,10 @@ find_package(LZ4 REQUIRED)
if (USE_QT) if (USE_QT)
find_package(QT REQUIRED COMPONENTS Core NAMES Qt6 Qt5) find_package(QT REQUIRED COMPONENTS Core NAMES Qt6 Qt5)
if (QT_VERSION_MAJOR VERSION_EQUAL 5) if (QT_VERSION_MAJOR VERSION_EQUAL 5)
find_package(Qt5 5.15 COMPONENTS Core Widgets Network OpenGL REQUIRED) find_package(Qt5 5.15 COMPONENTS Core Widgets Network OpenGL REQUIRED)
else() else()
find_package(Qt6 COMPONENTS Core Widgets Network OpenGL REQUIRED) find_package(Qt6 COMPONENTS Core Widgets Network OpenGL REQUIRED)
endif() endif()
message(STATUS "Using Qt${QT_VERSION}") message(STATUS "Using Qt${QT_VERSION}")
endif() endif()
@ -509,7 +509,7 @@ include_directories(
link_directories(${SDL2_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ${COLLADA_DOM_LIBRARY_DIRS}) link_directories(${SDL2_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ${COLLADA_DOM_LIBRARY_DIRS})
if(MYGUI_STATIC) if(MYGUI_STATIC)
add_definitions(-DMYGUI_STATIC) add_definitions(-DMYGUI_STATIC)
endif (MYGUI_STATIC) endif (MYGUI_STATIC)
if (APPLE) if (APPLE)
@ -638,31 +638,31 @@ if (BUILD_OPENMW)
endif() endif()
if (BUILD_BSATOOL) if (BUILD_BSATOOL)
add_subdirectory( apps/bsatool ) add_subdirectory( apps/bsatool )
endif() endif()
if (BUILD_ESMTOOL) if (BUILD_ESMTOOL)
add_subdirectory( apps/esmtool ) add_subdirectory( apps/esmtool )
endif() endif()
if (BUILD_LAUNCHER) if (BUILD_LAUNCHER)
add_subdirectory( apps/launcher ) add_subdirectory( apps/launcher )
endif() endif()
if (BUILD_MWINIIMPORTER) if (BUILD_MWINIIMPORTER)
add_subdirectory( apps/mwiniimporter ) add_subdirectory( apps/mwiniimporter )
endif() endif()
if (BUILD_ESSIMPORTER) if (BUILD_ESSIMPORTER)
add_subdirectory (apps/essimporter ) add_subdirectory (apps/essimporter )
endif() endif()
if (BUILD_OPENCS) if (BUILD_OPENCS)
add_subdirectory (apps/opencs) add_subdirectory (apps/opencs)
endif() endif()
if (BUILD_WIZARD) if (BUILD_WIZARD)
add_subdirectory(apps/wizard) add_subdirectory(apps/wizard)
endif() endif()
if (BUILD_NIFTEST) if (BUILD_NIFTEST)
@ -671,136 +671,136 @@ endif(BUILD_NIFTEST)
# UnitTests # UnitTests
if (BUILD_UNITTESTS) if (BUILD_UNITTESTS)
add_subdirectory( apps/openmw_test_suite ) add_subdirectory( apps/openmw_test_suite )
endif() endif()
if (BUILD_BENCHMARKS) if (BUILD_BENCHMARKS)
add_subdirectory(apps/benchmarks) add_subdirectory(apps/benchmarks)
endif() endif()
if (BUILD_NAVMESHTOOL) if (BUILD_NAVMESHTOOL)
add_subdirectory(apps/navmeshtool) add_subdirectory(apps/navmeshtool)
endif() endif()
if (BUILD_BULLETOBJECTTOOL) if (BUILD_BULLETOBJECTTOOL)
add_subdirectory( apps/bulletobjecttool ) add_subdirectory( apps/bulletobjecttool )
endif() endif()
if (WIN32) if (WIN32)
if (MSVC) if (MSVC)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "$(SolutionDir)$(Configuration)" ) set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "$(SolutionDir)$(Configuration)" )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "$(ProjectDir)$(Configuration)" ) set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "$(ProjectDir)$(Configuration)" )
endforeach( OUTPUTCONFIG ) endforeach( OUTPUTCONFIG )
if (USE_DEBUG_CONSOLE AND BUILD_OPENMW) if (USE_DEBUG_CONSOLE AND BUILD_OPENMW)
set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE") set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:CONSOLE")
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE") set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:CONSOLE")
set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_CONSOLE>) set_target_properties(openmw PROPERTIES COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_CONSOLE>)
elseif (BUILD_OPENMW) elseif (BUILD_OPENMW)
# Turn off debug console, debug output will be written to visual studio output instead # Turn off debug console, debug output will be written to visual studio output instead
set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS") set_target_properties(openmw PROPERTIES LINK_FLAGS_DEBUG "/SUBSYSTEM:WINDOWS")
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:WINDOWS") set_target_properties(openmw PROPERTIES LINK_FLAGS_RELWITHDEBINFO "/SUBSYSTEM:WINDOWS")
endif() endif()
if (BUILD_OPENMW) if (BUILD_OPENMW)
# Release builds don't use the debug console # Release builds don't use the debug console
set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS") set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
endif() endif()
# Play a bit with the warning levels # Play a bit with the warning levels
set(WARNINGS "/W4") set(WARNINGS "/W4")
set(WARNINGS_DISABLE set(WARNINGS_DISABLE
4100 # Unreferenced formal parameter (-Wunused-parameter) 4100 # Unreferenced formal parameter (-Wunused-parameter)
4127 # Conditional expression is constant 4127 # Conditional expression is constant
4996 # Function was declared deprecated 4996 # Function was declared deprecated
5054 # Deprecated operations between enumerations of different types caused by Qt headers 5054 # Deprecated operations between enumerations of different types caused by Qt headers
) )
if( "${MyGUI_VERSION}" VERSION_LESS_EQUAL "3.4.0" ) if( "${MyGUI_VERSION}" VERSION_LESS_EQUAL "3.4.0" )
set(WARNINGS_DISABLE ${WARNINGS_DISABLE} set(WARNINGS_DISABLE ${WARNINGS_DISABLE}
4866 # compiler may not enforce left-to-right evaluation order for call 4866 # compiler may not enforce left-to-right evaluation order for call
) )
endif() endif()
if( "${MyGUI_VERSION}" VERSION_LESS_EQUAL "3.4.1" ) if( "${MyGUI_VERSION}" VERSION_LESS_EQUAL "3.4.1" )
set(WARNINGS_DISABLE ${WARNINGS_DISABLE} set(WARNINGS_DISABLE ${WARNINGS_DISABLE}
4275 # non dll-interface class 'MyGUI::delegates::IDelegateUnlink' used as base for dll-interface class 'MyGUI::Widget' 4275 # non dll-interface class 'MyGUI::delegates::IDelegateUnlink' used as base for dll-interface class 'MyGUI::Widget'
) )
endif() endif()
foreach(d ${WARNINGS_DISABLE}) foreach(d ${WARNINGS_DISABLE})
set(WARNINGS "${WARNINGS} /wd${d}") set(WARNINGS "${WARNINGS} /wd${d}")
endforeach(d) endforeach(d)
if(OPENMW_MSVC_WERROR) if(OPENMW_MSVC_WERROR)
set(WARNINGS "${WARNINGS} /WX") set(WARNINGS "${WARNINGS} /WX")
endif() endif()
set_target_properties(components PROPERTIES COMPILE_FLAGS "${WARNINGS}") set_target_properties(components PROPERTIES COMPILE_FLAGS "${WARNINGS}")
set_target_properties(osg-ffmpeg-videoplayer PROPERTIES COMPILE_FLAGS "${WARNINGS}") set_target_properties(osg-ffmpeg-videoplayer PROPERTIES COMPILE_FLAGS "${WARNINGS}")
if (MSVC_VERSION GREATER_EQUAL 1915 AND MSVC_VERSION LESS 1920) if (MSVC_VERSION GREATER_EQUAL 1915 AND MSVC_VERSION LESS 1920)
target_compile_definitions(components INTERFACE _ENABLE_EXTENDED_ALIGNED_STORAGE) target_compile_definitions(components INTERFACE _ENABLE_EXTENDED_ALIGNED_STORAGE)
endif() endif()
if (BUILD_BSATOOL) if (BUILD_BSATOOL)
set_target_properties(bsatool PROPERTIES COMPILE_FLAGS "${WARNINGS}") set_target_properties(bsatool PROPERTIES COMPILE_FLAGS "${WARNINGS}")
endif() endif()
if (BUILD_ESMTOOL) if (BUILD_ESMTOOL)
set_target_properties(esmtool PROPERTIES COMPILE_FLAGS "${WARNINGS}") set_target_properties(esmtool PROPERTIES COMPILE_FLAGS "${WARNINGS}")
endif() endif()
if (BUILD_ESSIMPORTER) if (BUILD_ESSIMPORTER)
set_target_properties(openmw-essimporter PROPERTIES COMPILE_FLAGS "${WARNINGS}") set_target_properties(openmw-essimporter PROPERTIES COMPILE_FLAGS "${WARNINGS}")
endif() endif()
if (BUILD_LAUNCHER) if (BUILD_LAUNCHER)
set_target_properties(openmw-launcher PROPERTIES COMPILE_FLAGS "${WARNINGS}") set_target_properties(openmw-launcher PROPERTIES COMPILE_FLAGS "${WARNINGS}")
endif() endif()
if (BUILD_MWINIIMPORTER) if (BUILD_MWINIIMPORTER)
set_target_properties(openmw-iniimporter PROPERTIES COMPILE_FLAGS "${WARNINGS}") set_target_properties(openmw-iniimporter PROPERTIES COMPILE_FLAGS "${WARNINGS}")
endif() endif()
if (BUILD_OPENCS) if (BUILD_OPENCS)
set_target_properties(openmw-cs PROPERTIES COMPILE_FLAGS "${WARNINGS}") set_target_properties(openmw-cs PROPERTIES COMPILE_FLAGS "${WARNINGS}")
endif() endif()
if (BUILD_OPENMW) if (BUILD_OPENMW)
set_target_properties(openmw PROPERTIES COMPILE_FLAGS "${WARNINGS}") set_target_properties(openmw PROPERTIES COMPILE_FLAGS "${WARNINGS}")
endif() endif()
if (BUILD_WIZARD) if (BUILD_WIZARD)
set_target_properties(openmw-wizard PROPERTIES COMPILE_FLAGS "${WARNINGS}") set_target_properties(openmw-wizard PROPERTIES COMPILE_FLAGS "${WARNINGS}")
endif() endif()
if (BUILD_UNITTESTS) if (BUILD_UNITTESTS)
set_target_properties(openmw_test_suite PROPERTIES COMPILE_FLAGS "${WARNINGS}") set_target_properties(openmw_test_suite PROPERTIES COMPILE_FLAGS "${WARNINGS}")
endif() endif()
if (BUILD_BENCHMARKS) if (BUILD_BENCHMARKS)
set_target_properties(openmw_detournavigator_navmeshtilescache_benchmark PROPERTIES COMPILE_FLAGS "${WARNINGS}") set_target_properties(openmw_detournavigator_navmeshtilescache_benchmark PROPERTIES COMPILE_FLAGS "${WARNINGS}")
endif() endif()
if (BUILD_NAVMESHTOOL) if (BUILD_NAVMESHTOOL)
set_target_properties(openmw-navmeshtool PROPERTIES COMPILE_FLAGS "${WARNINGS}") set_target_properties(openmw-navmeshtool PROPERTIES COMPILE_FLAGS "${WARNINGS}")
endif() endif()
if (BUILD_BULLETOBJECTTOOL) if (BUILD_BULLETOBJECTTOOL)
set(WARNINGS "${WARNINGS} ${MT_BUILD}") set(WARNINGS "${WARNINGS} ${MT_BUILD}")
set_target_properties(openmw-bulletobjecttool PROPERTIES COMPILE_FLAGS "${WARNINGS}") set_target_properties(openmw-bulletobjecttool PROPERTIES COMPILE_FLAGS "${WARNINGS}")
endif() endif()
endif(MSVC) endif(MSVC)
# TODO: At some point release builds should not use the console but rather write to a log file # TODO: At some point release builds should not use the console but rather write to a log file
#set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS") #set_target_properties(openmw PROPERTIES LINK_FLAGS_RELEASE "/SUBSYSTEM:WINDOWS")
#set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS") #set_target_properties(openmw PROPERTIES LINK_FLAGS_MINSIZEREL "/SUBSYSTEM:WINDOWS")
endif() endif()
if (BUILD_OPENMW AND APPLE) if (BUILD_OPENMW AND APPLE)
@ -829,11 +829,11 @@ if (OPENMW_OSX_DEPLOYMENT AND APPLE)
configure_file("${OpenMW_SOURCE_DIR}/files/mac/qt.conf" "${APP_BUNDLE_DIR}/Contents/Resources/qt.conf" COPYONLY) configure_file("${OpenMW_SOURCE_DIR}/files/mac/qt.conf" "${APP_BUNDLE_DIR}/Contents/Resources/qt.conf" COPYONLY)
if (BUILD_OPENCS) if (BUILD_OPENCS)
get_property(OPENCS_BUNDLE_NAME_TMP TARGET openmw-cs PROPERTY OUTPUT_NAME) get_property(OPENCS_BUNDLE_NAME_TMP TARGET openmw-cs PROPERTY OUTPUT_NAME)
set(OPENCS_BUNDLE_NAME "${OPENCS_BUNDLE_NAME_TMP}.app") set(OPENCS_BUNDLE_NAME "${OPENCS_BUNDLE_NAME_TMP}.app")
configure_file("${QT_COCOA_PLUGIN_PATH}" "${OPENCS_BUNDLE_NAME}/Contents/PlugIns/${QT_COCOA_PLUGIN_GROUP}/${QT_COCOA_PLUGIN_NAME}" COPYONLY) configure_file("${QT_COCOA_PLUGIN_PATH}" "${OPENCS_BUNDLE_NAME}/Contents/PlugIns/${QT_COCOA_PLUGIN_GROUP}/${QT_COCOA_PLUGIN_NAME}" COPYONLY)
configure_file("${QT_QMACSTYLE_PLUGIN_PATH}" "${OPENCS_BUNDLE_NAME}/Contents/PlugIns/${QT_QMACSTYLE_PLUGIN_GROUP}/${QT_QMACSTYLE_PLUGIN_NAME}" COPYONLY) configure_file("${QT_QMACSTYLE_PLUGIN_PATH}" "${OPENCS_BUNDLE_NAME}/Contents/PlugIns/${QT_QMACSTYLE_PLUGIN_GROUP}/${QT_QMACSTYLE_PLUGIN_NAME}" COPYONLY)
configure_file("${OpenMW_SOURCE_DIR}/files/mac/qt.conf" "${OPENCS_BUNDLE_NAME}/Contents/Resources/qt.conf" COPYONLY) configure_file("${OpenMW_SOURCE_DIR}/files/mac/qt.conf" "${OPENCS_BUNDLE_NAME}/Contents/Resources/qt.conf" COPYONLY)
endif () endif ()
install(DIRECTORY "${APP_BUNDLE_DIR}" USE_SOURCE_PERMISSIONS DESTINATION "." COMPONENT Runtime) install(DIRECTORY "${APP_BUNDLE_DIR}" USE_SOURCE_PERMISSIONS DESTINATION "." COMPONENT Runtime)

@ -13,3 +13,8 @@ endif()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(openmw_detournavigator_navmeshtilescache_benchmark PRIVATE <algorithm>) target_precompile_headers(openmw_detournavigator_navmeshtilescache_benchmark PRIVATE <algorithm>)
endif() endif()
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw_detournavigator_navmeshtilescache_benchmark PRIVATE --coverage)
target_link_libraries(openmw_detournavigator_navmeshtilescache_benchmark gcov)
endif()

@ -1,21 +1,21 @@
set(BSATOOL set(BSATOOL
bsatool.cpp bsatool.cpp
) )
source_group(apps\\bsatool FILES ${BSATOOL}) source_group(apps\\bsatool FILES ${BSATOOL})
# Main executable # Main executable
openmw_add_executable(bsatool openmw_add_executable(bsatool
${BSATOOL} ${BSATOOL}
) )
target_link_libraries(bsatool target_link_libraries(bsatool
${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}
components components
) )
if (BUILD_WITH_CODE_COVERAGE) if (BUILD_WITH_CODE_COVERAGE)
add_definitions (--coverage) target_compile_options(bsatool PRIVATE --coverage)
target_link_libraries(bsatool gcov) target_link_libraries(bsatool gcov)
endif() endif()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)

@ -11,7 +11,7 @@ target_link_libraries(openmw-bulletobjecttool
) )
if (BUILD_WITH_CODE_COVERAGE) if (BUILD_WITH_CODE_COVERAGE)
add_definitions(--coverage) target_compile_options(openmw-bulletobjecttool PRIVATE --coverage)
target_link_libraries(openmw-bulletobjecttool gcov) target_link_libraries(openmw-bulletobjecttool gcov)
endif() endif()

@ -1,28 +1,28 @@
set(ESMTOOL set(ESMTOOL
esmtool.cpp esmtool.cpp
labels.hpp labels.hpp
labels.cpp labels.cpp
record.hpp record.hpp
record.cpp record.cpp
arguments.hpp arguments.hpp
tes4.hpp tes4.hpp
tes4.cpp tes4.cpp
) )
source_group(apps\\esmtool FILES ${ESMTOOL}) source_group(apps\\esmtool FILES ${ESMTOOL})
# Main executable # Main executable
openmw_add_executable(esmtool openmw_add_executable(esmtool
${ESMTOOL} ${ESMTOOL}
) )
target_link_libraries(esmtool target_link_libraries(esmtool
${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY}
components components
) )
if (BUILD_WITH_CODE_COVERAGE) if (BUILD_WITH_CODE_COVERAGE)
add_definitions (--coverage) target_compile_options(esmtool PRIVATE --coverage)
target_link_libraries(esmtool gcov) target_link_libraries(esmtool gcov)
endif() endif()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)

@ -39,12 +39,12 @@ target_link_libraries(openmw-essimporter
) )
if (BUILD_WITH_CODE_COVERAGE) if (BUILD_WITH_CODE_COVERAGE)
add_definitions (--coverage) target_compile_options(openmw-essimporter PRIVATE --coverage)
target_link_libraries(openmw-essimporter gcov) target_link_libraries(openmw-essimporter gcov)
endif() endif()
if (WIN32) if (WIN32)
INSTALL(TARGETS openmw-essimporter RUNTIME DESTINATION ".") INSTALL(TARGETS openmw-essimporter RUNTIME DESTINATION ".")
endif(WIN32) endif(WIN32)
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)

@ -85,8 +85,8 @@ target_link_libraries(openmw-launcher
target_link_libraries(openmw-launcher Qt::Widgets Qt::Core) target_link_libraries(openmw-launcher Qt::Widgets Qt::Core)
if (BUILD_WITH_CODE_COVERAGE) if (BUILD_WITH_CODE_COVERAGE)
add_definitions (--coverage) target_compile_options(openmw-launcher PRIVATE --coverage)
target_link_libraries(openmw-launcher gcov) target_link_libraries(openmw-launcher gcov)
endif() endif()
if(USE_QT) if(USE_QT)

@ -25,12 +25,12 @@ if (WIN32)
endif(WIN32) endif(WIN32)
if (MINGW) if (MINGW)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -municode") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -municode")
endif() endif()
if (BUILD_WITH_CODE_COVERAGE) if (BUILD_WITH_CODE_COVERAGE)
add_definitions (--coverage) target_compile_options(openmw-iniimporter PRIVATE --coverage)
target_link_libraries(openmw-iniimporter gcov) target_link_libraries(openmw-iniimporter gcov)
endif() endif()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)

@ -13,7 +13,7 @@ target_link_libraries(openmw-navmeshtool
) )
if (BUILD_WITH_CODE_COVERAGE) if (BUILD_WITH_CODE_COVERAGE)
add_definitions(--coverage) target_compile_options(openmw-navmeshtool PRIVATE --coverage)
target_link_libraries(openmw-navmeshtool gcov) target_link_libraries(openmw-navmeshtool gcov)
endif() endif()

@ -9,12 +9,12 @@ openmw_add_executable(niftest
) )
target_link_libraries(niftest target_link_libraries(niftest
components components
) )
if (BUILD_WITH_CODE_COVERAGE) if (BUILD_WITH_CODE_COVERAGE)
add_definitions (--coverage) target_compile_options(niftest PRIVATE --coverage)
target_link_libraries(niftest gcov) target_link_libraries(niftest gcov)
endif() endif()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)

@ -260,6 +260,11 @@ if(USE_QT)
set_property(TARGET openmw-cs PROPERTY AUTOMOC ON) set_property(TARGET openmw-cs PROPERTY AUTOMOC ON)
endif(USE_QT) endif(USE_QT)
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(openmw-cs PRIVATE --coverage)
target_link_libraries(openmw-cs gcov)
endif()
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
target_precompile_headers(openmw-cs PRIVATE target_precompile_headers(openmw-cs PRIVATE
<boost/filesystem.hpp> <boost/filesystem.hpp>

@ -192,12 +192,12 @@ if (USE_SYSTEM_TINYXML)
endif() endif()
if (NOT UNIX) if (NOT UNIX)
target_link_libraries(openmw ${SDL2MAIN_LIBRARY}) target_link_libraries(openmw ${SDL2MAIN_LIBRARY})
endif() endif()
# Fix for not visible pthreads functions for linker with glibc 2.15 # Fix for not visible pthreads functions for linker with glibc 2.15
if (UNIX AND NOT APPLE) if (UNIX AND NOT APPLE)
target_link_libraries(openmw ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(openmw ${CMAKE_THREAD_LIBS_INIT})
endif() endif()
if(APPLE) if(APPLE)
@ -230,8 +230,8 @@ if(APPLE)
endif(APPLE) endif(APPLE)
if (BUILD_WITH_CODE_COVERAGE) if (BUILD_WITH_CODE_COVERAGE)
add_definitions (--coverage) target_compile_options(openmw PRIVATE --coverage)
target_link_libraries(openmw gcov) target_link_libraries(openmw gcov)
endif() endif()
if (WIN32) if (WIN32)

@ -108,7 +108,7 @@ if (UNIX AND NOT APPLE)
endif() endif()
if (BUILD_WITH_CODE_COVERAGE) if (BUILD_WITH_CODE_COVERAGE)
add_definitions(--coverage) target_compile_options(openmw_test_suite PRIVATE --coverage)
target_link_libraries(openmw_test_suite gcov) target_link_libraries(openmw_test_suite gcov)
endif() endif()

@ -94,13 +94,13 @@ if(DPKG_PROGRAM)
endif() endif()
if (BUILD_WITH_CODE_COVERAGE) if (BUILD_WITH_CODE_COVERAGE)
add_definitions (--coverage) target_compile_options(openmw-wizard PRIVATE --coverage)
target_link_libraries(openmw-wizard gcov) target_link_libraries(openmw-wizard gcov)
endif() endif()
# Workaround for binutil => 2.23 problem when linking, should be fixed eventually upstream # Workaround for binutil => 2.23 problem when linking, should be fixed eventually upstream
if (CMAKE_SYSTEM_NAME MATCHES "Linux") if (CMAKE_SYSTEM_NAME MATCHES "Linux")
target_link_libraries(openmw-wizard dl Xt) target_link_libraries(openmw-wizard dl Xt)
endif() endif()
if (WIN32) if (WIN32)

@ -112,64 +112,64 @@ endmacro (opencs_hdrs)
include(CMakeParseArguments) include(CMakeParseArguments)
macro (openmw_add_executable target) macro (openmw_add_executable target)
set(OMW_ADD_EXE_OPTIONS WIN32 MACOSX_BUNDLE EXCLUDE_FROM_ALL) set(OMW_ADD_EXE_OPTIONS WIN32 MACOSX_BUNDLE EXCLUDE_FROM_ALL)
set(OMW_ADD_EXE_VALUES) set(OMW_ADD_EXE_VALUES)
set(OMW_ADD_EXE_MULTI_VALUES) set(OMW_ADD_EXE_MULTI_VALUES)
cmake_parse_arguments(OMW_ADD_EXE "${OMW_ADD_EXE_OPTIONS}" "${OMW_ADD_EXE_VALUES}" "${OMW_ADD_EXE_MULTI_VALUES}" ${ARGN}) cmake_parse_arguments(OMW_ADD_EXE "${OMW_ADD_EXE_OPTIONS}" "${OMW_ADD_EXE_VALUES}" "${OMW_ADD_EXE_MULTI_VALUES}" ${ARGN})
if (OMW_ADD_EXE_WIN32) if (OMW_ADD_EXE_WIN32)
set(OMW_ADD_EXE_WIN32_VALUE WIN32) set(OMW_ADD_EXE_WIN32_VALUE WIN32)
endif (OMW_ADD_EXE_WIN32) endif (OMW_ADD_EXE_WIN32)
if (OMW_ADD_EXE_MACOSX_BUNDLE) if (OMW_ADD_EXE_MACOSX_BUNDLE)
set(OMW_ADD_EXE_MACOSX_BUNDLE_VALUE MACOSX_BUNDLE) set(OMW_ADD_EXE_MACOSX_BUNDLE_VALUE MACOSX_BUNDLE)
endif (OMW_ADD_EXE_MACOSX_BUNDLE) endif (OMW_ADD_EXE_MACOSX_BUNDLE)
if (OMW_ADD_EXE_EXCLUDE_FROM_ALL) if (OMW_ADD_EXE_EXCLUDE_FROM_ALL)
set(OMW_ADD_EXE_EXCLUDE_FROM_ALL_VALUE EXCLUDE_FROM_ALL) set(OMW_ADD_EXE_EXCLUDE_FROM_ALL_VALUE EXCLUDE_FROM_ALL)
endif (OMW_ADD_EXE_EXCLUDE_FROM_ALL) endif (OMW_ADD_EXE_EXCLUDE_FROM_ALL)
add_executable(${target} ${OMW_ADD_EXE_WIN32_VALUE} ${OMW_ADD_EXE_MACOSX_BUNDLE_VALUE} ${OMW_ADD_EXE_EXCLUDE_FROM_ALL_VALUE} ${OMW_ADD_EXE_UNPARSED_ARGUMENTS}) add_executable(${target} ${OMW_ADD_EXE_WIN32_VALUE} ${OMW_ADD_EXE_MACOSX_BUNDLE_VALUE} ${OMW_ADD_EXE_EXCLUDE_FROM_ALL_VALUE} ${OMW_ADD_EXE_UNPARSED_ARGUMENTS})
if (MSVC) if (MSVC)
if (CMAKE_VERSION VERSION_GREATER 3.8 OR CMAKE_VERSION VERSION_EQUAL 3.8) if (CMAKE_VERSION VERSION_GREATER 3.8 OR CMAKE_VERSION VERSION_EQUAL 3.8)
set_target_properties(${target} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "$<TARGET_FILE_DIR:${target}>") set_target_properties(${target} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "$<TARGET_FILE_DIR:${target}>")
endif (CMAKE_VERSION VERSION_GREATER 3.8 OR CMAKE_VERSION VERSION_EQUAL 3.8) endif (CMAKE_VERSION VERSION_GREATER 3.8 OR CMAKE_VERSION VERSION_EQUAL 3.8)
endif (MSVC) endif (MSVC)
endmacro (openmw_add_executable) endmacro (openmw_add_executable)
macro (get_generator_is_multi_config VALUE) macro (get_generator_is_multi_config VALUE)
if (DEFINED generator_is_multi_config_var) if (DEFINED generator_is_multi_config_var)
set(${VALUE} ${generator_is_multi_config_var}) set(${VALUE} ${generator_is_multi_config_var})
else (DEFINED generator_is_multi_config_var) else (DEFINED generator_is_multi_config_var)
if (CMAKE_VERSION VERSION_GREATER 3.9 OR CMAKE_VERSION VERSION_EQUAL 3.9) if (CMAKE_VERSION VERSION_GREATER 3.9 OR CMAKE_VERSION VERSION_EQUAL 3.9)
get_cmake_property(${VALUE} GENERATOR_IS_MULTI_CONFIG) get_cmake_property(${VALUE} GENERATOR_IS_MULTI_CONFIG)
else (CMAKE_VERSION VERSION_GREATER 3.9 OR CMAKE_VERSION VERSION_EQUAL 3.9) else (CMAKE_VERSION VERSION_GREATER 3.9 OR CMAKE_VERSION VERSION_EQUAL 3.9)
list(LENGTH CMAKE_CONFIGURATION_TYPES ${VALUE}) list(LENGTH CMAKE_CONFIGURATION_TYPES ${VALUE})
endif (CMAKE_VERSION VERSION_GREATER 3.9 OR CMAKE_VERSION VERSION_EQUAL 3.9) endif (CMAKE_VERSION VERSION_GREATER 3.9 OR CMAKE_VERSION VERSION_EQUAL 3.9)
endif (DEFINED generator_is_multi_config_var) endif (DEFINED generator_is_multi_config_var)
endmacro (get_generator_is_multi_config) endmacro (get_generator_is_multi_config)
macro (copy_resource_file source_path destination_dir_base dest_path_relative) macro (copy_resource_file source_path destination_dir_base dest_path_relative)
get_generator_is_multi_config(multi_config) get_generator_is_multi_config(multi_config)
if (multi_config) if (multi_config)
foreach(cfgtype ${CMAKE_CONFIGURATION_TYPES}) foreach(cfgtype ${CMAKE_CONFIGURATION_TYPES})
configure_file(${source_path} "${destination_dir_base}/${cfgtype}/${dest_path_relative}" COPYONLY) configure_file(${source_path} "${destination_dir_base}/${cfgtype}/${dest_path_relative}" COPYONLY)
endforeach(cfgtype) endforeach(cfgtype)
else (multi_config) else (multi_config)
configure_file(${source_path} "${destination_dir_base}/${dest_path_relative}" COPYONLY) configure_file(${source_path} "${destination_dir_base}/${dest_path_relative}" COPYONLY)
endif (multi_config) endif (multi_config)
endmacro (copy_resource_file) endmacro (copy_resource_file)
macro (configure_resource_file source_path destination_dir_base dest_path_relative) macro (configure_resource_file source_path destination_dir_base dest_path_relative)
get_generator_is_multi_config(multi_config) get_generator_is_multi_config(multi_config)
if (multi_config) if (multi_config)
foreach(cfgtype ${CMAKE_CONFIGURATION_TYPES}) foreach(cfgtype ${CMAKE_CONFIGURATION_TYPES})
configure_file(${source_path} "${destination_dir_base}/${cfgtype}/${dest_path_relative}") configure_file(${source_path} "${destination_dir_base}/${cfgtype}/${dest_path_relative}")
endforeach(cfgtype) endforeach(cfgtype)
else (multi_config) else (multi_config)
configure_file(${source_path} "${destination_dir_base}/${dest_path_relative}") configure_file(${source_path} "${destination_dir_base}/${dest_path_relative}")
endif (multi_config) endif (multi_config)
endmacro (configure_resource_file) endmacro (configure_resource_file)
macro (pack_resource_file source_path destination_dir_base dest_path_relative) macro (pack_resource_file source_path destination_dir_base dest_path_relative)
@ -185,8 +185,8 @@ macro (pack_resource_file source_path destination_dir_base dest_path_relative)
endmacro (pack_resource_file) endmacro (pack_resource_file)
macro (copy_all_resource_files source_dir destination_dir_base destination_dir_relative files) macro (copy_all_resource_files source_dir destination_dir_base destination_dir_relative files)
foreach (f ${files}) foreach (f ${files})
get_filename_component(filename ${f} NAME) get_filename_component(filename ${f} NAME)
copy_resource_file("${source_dir}/${f}" "${destination_dir_base}" "${destination_dir_relative}/${f}") copy_resource_file("${source_dir}/${f}" "${destination_dir_base}" "${destination_dir_relative}/${f}")
endforeach (f) endforeach (f)
endmacro (copy_all_resource_files) endmacro (copy_all_resource_files)

@ -462,6 +462,11 @@ if (USE_QT)
add_library(components_qt STATIC ${COMPONENT_QT_FILES} ${ESM_UI_HDR}) add_library(components_qt STATIC ${COMPONENT_QT_FILES} ${ESM_UI_HDR})
target_link_libraries(components_qt components Qt::Widgets Qt::Core) target_link_libraries(components_qt components Qt::Widgets Qt::Core)
target_compile_definitions(components_qt PRIVATE OPENMW_DOC_BASEURL="${OPENMW_DOC_BASEURL}") target_compile_definitions(components_qt PRIVATE OPENMW_DOC_BASEURL="${OPENMW_DOC_BASEURL}")
if (BUILD_WITH_CODE_COVERAGE)
target_compile_options(components_qt PRIVATE --coverage)
target_link_libraries(components_qt gcov)
endif()
endif() endif()
if (GIT_CHECKOUT) if (GIT_CHECKOUT)
@ -483,11 +488,11 @@ endif()
# Fix for not visible pthreads functions for linker with glibc 2.15 # Fix for not visible pthreads functions for linker with glibc 2.15
if (UNIX AND NOT APPLE) if (UNIX AND NOT APPLE)
target_link_libraries(components ${CMAKE_THREAD_LIBS_INIT}) target_link_libraries(components ${CMAKE_THREAD_LIBS_INIT})
endif() endif()
if (BUILD_WITH_CODE_COVERAGE) if (BUILD_WITH_CODE_COVERAGE)
add_definitions(--coverage) target_compile_options(components PRIVATE --coverage)
target_link_libraries(components gcov) target_link_libraries(components gcov)
endif() endif()

Loading…
Cancel
Save