From 8031b9a16c2d7186e3ddbe5bdd96ce0cf51e95d1 Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 10 Mar 2023 14:42:43 +0100 Subject: [PATCH 1/5] Use spaces only for identation in CMakeLists.txt --- CMakeLists.txt | 6 +- apps/bsatool/CMakeLists.txt | 4 +- cmake/OpenMWMacros.cmake | 106 ++++++++++++++++++------------------ 3 files changed, 58 insertions(+), 58 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e2d538ae6c..cff1960db9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -237,10 +237,10 @@ find_package(LZ4 REQUIRED) if (USE_QT) 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) - else() - find_package(Qt6 COMPONENTS Core Widgets Network OpenGL REQUIRED) + else() + find_package(Qt6 COMPONENTS Core Widgets Network OpenGL REQUIRED) endif() message(STATUS "Using Qt${QT_VERSION}") endif() diff --git a/apps/bsatool/CMakeLists.txt b/apps/bsatool/CMakeLists.txt index 6312c33aaf..058519bba5 100644 --- a/apps/bsatool/CMakeLists.txt +++ b/apps/bsatool/CMakeLists.txt @@ -1,11 +1,11 @@ set(BSATOOL - bsatool.cpp + bsatool.cpp ) source_group(apps\\bsatool FILES ${BSATOOL}) # Main executable openmw_add_executable(bsatool - ${BSATOOL} + ${BSATOOL} ) target_link_libraries(bsatool diff --git a/cmake/OpenMWMacros.cmake b/cmake/OpenMWMacros.cmake index 2cb7e6eec8..991125526d 100644 --- a/cmake/OpenMWMacros.cmake +++ b/cmake/OpenMWMacros.cmake @@ -112,64 +112,64 @@ endmacro (opencs_hdrs) include(CMakeParseArguments) macro (openmw_add_executable target) - set(OMW_ADD_EXE_OPTIONS WIN32 MACOSX_BUNDLE EXCLUDE_FROM_ALL) - set(OMW_ADD_EXE_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}) - - if (OMW_ADD_EXE_WIN32) - set(OMW_ADD_EXE_WIN32_VALUE WIN32) - endif (OMW_ADD_EXE_WIN32) - - if (OMW_ADD_EXE_MACOSX_BUNDLE) - set(OMW_ADD_EXE_MACOSX_BUNDLE_VALUE MACOSX_BUNDLE) - endif (OMW_ADD_EXE_MACOSX_BUNDLE) - - if (OMW_ADD_EXE_EXCLUDE_FROM_ALL) - set(OMW_ADD_EXE_EXCLUDE_FROM_ALL_VALUE 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}) - - if (MSVC) - if (CMAKE_VERSION VERSION_GREATER 3.8 OR CMAKE_VERSION VERSION_EQUAL 3.8) - set_target_properties(${target} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "$") - endif (CMAKE_VERSION VERSION_GREATER 3.8 OR CMAKE_VERSION VERSION_EQUAL 3.8) - endif (MSVC) + set(OMW_ADD_EXE_OPTIONS WIN32 MACOSX_BUNDLE EXCLUDE_FROM_ALL) + set(OMW_ADD_EXE_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}) + + if (OMW_ADD_EXE_WIN32) + set(OMW_ADD_EXE_WIN32_VALUE WIN32) + endif (OMW_ADD_EXE_WIN32) + + if (OMW_ADD_EXE_MACOSX_BUNDLE) + set(OMW_ADD_EXE_MACOSX_BUNDLE_VALUE MACOSX_BUNDLE) + endif (OMW_ADD_EXE_MACOSX_BUNDLE) + + if (OMW_ADD_EXE_EXCLUDE_FROM_ALL) + set(OMW_ADD_EXE_EXCLUDE_FROM_ALL_VALUE 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}) + + if (MSVC) + if (CMAKE_VERSION VERSION_GREATER 3.8 OR CMAKE_VERSION VERSION_EQUAL 3.8) + set_target_properties(${target} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "$") + endif (CMAKE_VERSION VERSION_GREATER 3.8 OR CMAKE_VERSION VERSION_EQUAL 3.8) + endif (MSVC) endmacro (openmw_add_executable) macro (get_generator_is_multi_config VALUE) - if (DEFINED generator_is_multi_config_var) - set(${VALUE} ${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) - get_cmake_property(${VALUE} GENERATOR_IS_MULTI_CONFIG) - else (CMAKE_VERSION VERSION_GREATER 3.9 OR CMAKE_VERSION VERSION_EQUAL 3.9) - list(LENGTH CMAKE_CONFIGURATION_TYPES ${VALUE}) - endif (CMAKE_VERSION VERSION_GREATER 3.9 OR CMAKE_VERSION VERSION_EQUAL 3.9) - endif (DEFINED generator_is_multi_config_var) + if (DEFINED generator_is_multi_config_var) + set(${VALUE} ${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) + get_cmake_property(${VALUE} GENERATOR_IS_MULTI_CONFIG) + else (CMAKE_VERSION VERSION_GREATER 3.9 OR CMAKE_VERSION VERSION_EQUAL 3.9) + list(LENGTH CMAKE_CONFIGURATION_TYPES ${VALUE}) + endif (CMAKE_VERSION VERSION_GREATER 3.9 OR CMAKE_VERSION VERSION_EQUAL 3.9) + endif (DEFINED generator_is_multi_config_var) endmacro (get_generator_is_multi_config) macro (copy_resource_file source_path destination_dir_base dest_path_relative) - get_generator_is_multi_config(multi_config) - if (multi_config) - foreach(cfgtype ${CMAKE_CONFIGURATION_TYPES}) - configure_file(${source_path} "${destination_dir_base}/${cfgtype}/${dest_path_relative}" COPYONLY) - endforeach(cfgtype) - else (multi_config) - configure_file(${source_path} "${destination_dir_base}/${dest_path_relative}" COPYONLY) - endif (multi_config) + get_generator_is_multi_config(multi_config) + if (multi_config) + foreach(cfgtype ${CMAKE_CONFIGURATION_TYPES}) + configure_file(${source_path} "${destination_dir_base}/${cfgtype}/${dest_path_relative}" COPYONLY) + endforeach(cfgtype) + else (multi_config) + configure_file(${source_path} "${destination_dir_base}/${dest_path_relative}" COPYONLY) + endif (multi_config) endmacro (copy_resource_file) macro (configure_resource_file source_path destination_dir_base dest_path_relative) - get_generator_is_multi_config(multi_config) - if (multi_config) - foreach(cfgtype ${CMAKE_CONFIGURATION_TYPES}) - configure_file(${source_path} "${destination_dir_base}/${cfgtype}/${dest_path_relative}") - endforeach(cfgtype) - else (multi_config) - configure_file(${source_path} "${destination_dir_base}/${dest_path_relative}") - endif (multi_config) + get_generator_is_multi_config(multi_config) + if (multi_config) + foreach(cfgtype ${CMAKE_CONFIGURATION_TYPES}) + configure_file(${source_path} "${destination_dir_base}/${cfgtype}/${dest_path_relative}") + endforeach(cfgtype) + else (multi_config) + configure_file(${source_path} "${destination_dir_base}/${dest_path_relative}") + endif (multi_config) endmacro (configure_resource_file) 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) macro (copy_all_resource_files source_dir destination_dir_base destination_dir_relative files) - foreach (f ${files}) - get_filename_component(filename ${f} NAME) - copy_resource_file("${source_dir}/${f}" "${destination_dir_base}" "${destination_dir_relative}/${f}") - endforeach (f) + foreach (f ${files}) + get_filename_component(filename ${f} NAME) + copy_resource_file("${source_dir}/${f}" "${destination_dir_base}" "${destination_dir_relative}/${f}") + endforeach (f) endmacro (copy_all_resource_files) From cc066efa1176361f5af44c93dad39a21c2545cb1 Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 10 Mar 2023 15:01:18 +0100 Subject: [PATCH 2/5] Fix identation in CMakeLists.txt --- CMakeLists.txt | 230 +++++++++++++++--------------- apps/bsatool/CMakeLists.txt | 8 +- apps/esmtool/CMakeLists.txt | 26 ++-- apps/essimporter/CMakeLists.txt | 6 +- apps/launcher/CMakeLists.txt | 4 +- apps/mwiniimporter/CMakeLists.txt | 6 +- apps/niftest/CMakeLists.txt | 6 +- apps/openmw/CMakeLists.txt | 8 +- apps/wizard/CMakeLists.txt | 6 +- components/CMakeLists.txt | 2 +- 10 files changed, 151 insertions(+), 151 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cff1960db9..4954722843 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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. if (NOT BUILD_LAUNCHER AND NOT BUILD_OPENCS AND NOT BUILD_WIZARD) - set(USE_QT FALSE) + set(USE_QT FALSE) else() - set(USE_QT TRUE) + set(USE_QT TRUE) endif() # If the user doesn't supply a CMAKE_BUILD_TYPE via command line, choose one for them. @@ -227,7 +227,7 @@ if (WIN32) endif() if(MSVC) - add_compile_options("/utf-8") + add_compile_options("/utf-8") endif() # Dependencies @@ -509,7 +509,7 @@ include_directories( link_directories(${SDL2_LIBRARY_DIRS} ${Boost_LIBRARY_DIRS} ${COLLADA_DOM_LIBRARY_DIRS}) if(MYGUI_STATIC) - add_definitions(-DMYGUI_STATIC) + add_definitions(-DMYGUI_STATIC) endif (MYGUI_STATIC) if (APPLE) @@ -638,31 +638,31 @@ if (BUILD_OPENMW) endif() if (BUILD_BSATOOL) - add_subdirectory( apps/bsatool ) + add_subdirectory( apps/bsatool ) endif() if (BUILD_ESMTOOL) - add_subdirectory( apps/esmtool ) + add_subdirectory( apps/esmtool ) endif() if (BUILD_LAUNCHER) - add_subdirectory( apps/launcher ) + add_subdirectory( apps/launcher ) endif() if (BUILD_MWINIIMPORTER) - add_subdirectory( apps/mwiniimporter ) + add_subdirectory( apps/mwiniimporter ) endif() if (BUILD_ESSIMPORTER) - add_subdirectory (apps/essimporter ) + add_subdirectory (apps/essimporter ) endif() if (BUILD_OPENCS) - add_subdirectory (apps/opencs) + add_subdirectory (apps/opencs) endif() if (BUILD_WIZARD) - add_subdirectory(apps/wizard) + add_subdirectory(apps/wizard) endif() if (BUILD_NIFTEST) @@ -671,136 +671,136 @@ endif(BUILD_NIFTEST) # UnitTests if (BUILD_UNITTESTS) - add_subdirectory( apps/openmw_test_suite ) + add_subdirectory( apps/openmw_test_suite ) endif() if (BUILD_BENCHMARKS) - add_subdirectory(apps/benchmarks) + add_subdirectory(apps/benchmarks) endif() if (BUILD_NAVMESHTOOL) - add_subdirectory(apps/navmeshtool) + add_subdirectory(apps/navmeshtool) endif() if (BUILD_BULLETOBJECTTOOL) - add_subdirectory( apps/bulletobjecttool ) + add_subdirectory( apps/bulletobjecttool ) endif() if (WIN32) - if (MSVC) - foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) - string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) - set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "$(SolutionDir)$(Configuration)" ) - set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "$(ProjectDir)$(Configuration)" ) - endforeach( OUTPUTCONFIG ) - - if (USE_DEBUG_CONSOLE AND BUILD_OPENMW) - 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 COMPILE_DEFINITIONS $<$:_CONSOLE>) - elseif (BUILD_OPENMW) - # 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_RELWITHDEBINFO "/SUBSYSTEM:WINDOWS") - endif() + if (MSVC) + foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) + string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) + set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "$(SolutionDir)$(Configuration)" ) + set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} "$(ProjectDir)$(Configuration)" ) + endforeach( OUTPUTCONFIG ) + + if (USE_DEBUG_CONSOLE AND BUILD_OPENMW) + 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 COMPILE_DEFINITIONS $<$:_CONSOLE>) + elseif (BUILD_OPENMW) + # 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_RELWITHDEBINFO "/SUBSYSTEM:WINDOWS") + endif() - if (BUILD_OPENMW) - # 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_MINSIZEREL "/SUBSYSTEM:WINDOWS") - endif() + if (BUILD_OPENMW) + # 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_MINSIZEREL "/SUBSYSTEM:WINDOWS") + endif() - # Play a bit with the warning levels - - set(WARNINGS "/W4") - - set(WARNINGS_DISABLE - 4100 # Unreferenced formal parameter (-Wunused-parameter) - 4127 # Conditional expression is constant - 4996 # Function was declared deprecated - 5054 # Deprecated operations between enumerations of different types caused by Qt headers - ) - - if( "${MyGUI_VERSION}" VERSION_LESS_EQUAL "3.4.0" ) - set(WARNINGS_DISABLE ${WARNINGS_DISABLE} - 4866 # compiler may not enforce left-to-right evaluation order for call - ) - endif() + # Play a bit with the warning levels - if( "${MyGUI_VERSION}" VERSION_LESS_EQUAL "3.4.1" ) - set(WARNINGS_DISABLE ${WARNINGS_DISABLE} - 4275 # non dll-interface class 'MyGUI::delegates::IDelegateUnlink' used as base for dll-interface class 'MyGUI::Widget' - ) - endif() + set(WARNINGS "/W4") - foreach(d ${WARNINGS_DISABLE}) - set(WARNINGS "${WARNINGS} /wd${d}") - endforeach(d) + set(WARNINGS_DISABLE + 4100 # Unreferenced formal parameter (-Wunused-parameter) + 4127 # Conditional expression is constant + 4996 # Function was declared deprecated + 5054 # Deprecated operations between enumerations of different types caused by Qt headers + ) - if(OPENMW_MSVC_WERROR) - set(WARNINGS "${WARNINGS} /WX") - endif() + if( "${MyGUI_VERSION}" VERSION_LESS_EQUAL "3.4.0" ) + set(WARNINGS_DISABLE ${WARNINGS_DISABLE} + 4866 # compiler may not enforce left-to-right evaluation order for call + ) + endif() - set_target_properties(components 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) - target_compile_definitions(components INTERFACE _ENABLE_EXTENDED_ALIGNED_STORAGE) - endif() + if( "${MyGUI_VERSION}" VERSION_LESS_EQUAL "3.4.1" ) + set(WARNINGS_DISABLE ${WARNINGS_DISABLE} + 4275 # non dll-interface class 'MyGUI::delegates::IDelegateUnlink' used as base for dll-interface class 'MyGUI::Widget' + ) + endif() - if (BUILD_BSATOOL) - set_target_properties(bsatool PROPERTIES COMPILE_FLAGS "${WARNINGS}") - endif() + foreach(d ${WARNINGS_DISABLE}) + set(WARNINGS "${WARNINGS} /wd${d}") + endforeach(d) - if (BUILD_ESMTOOL) - set_target_properties(esmtool PROPERTIES COMPILE_FLAGS "${WARNINGS}") - endif() + if(OPENMW_MSVC_WERROR) + set(WARNINGS "${WARNINGS} /WX") + endif() - if (BUILD_ESSIMPORTER) - set_target_properties(openmw-essimporter PROPERTIES COMPILE_FLAGS "${WARNINGS}") - endif() + set_target_properties(components PROPERTIES COMPILE_FLAGS "${WARNINGS}") + set_target_properties(osg-ffmpeg-videoplayer PROPERTIES COMPILE_FLAGS "${WARNINGS}") - if (BUILD_LAUNCHER) - set_target_properties(openmw-launcher PROPERTIES COMPILE_FLAGS "${WARNINGS}") - endif() + if (MSVC_VERSION GREATER_EQUAL 1915 AND MSVC_VERSION LESS 1920) + target_compile_definitions(components INTERFACE _ENABLE_EXTENDED_ALIGNED_STORAGE) + endif() - if (BUILD_MWINIIMPORTER) - set_target_properties(openmw-iniimporter PROPERTIES COMPILE_FLAGS "${WARNINGS}") - endif() + if (BUILD_BSATOOL) + set_target_properties(bsatool PROPERTIES COMPILE_FLAGS "${WARNINGS}") + endif() - if (BUILD_OPENCS) - set_target_properties(openmw-cs PROPERTIES COMPILE_FLAGS "${WARNINGS}") - endif() + if (BUILD_ESMTOOL) + set_target_properties(esmtool PROPERTIES COMPILE_FLAGS "${WARNINGS}") + endif() - if (BUILD_OPENMW) - set_target_properties(openmw PROPERTIES COMPILE_FLAGS "${WARNINGS}") - endif() + if (BUILD_ESSIMPORTER) + set_target_properties(openmw-essimporter PROPERTIES COMPILE_FLAGS "${WARNINGS}") + endif() - if (BUILD_WIZARD) - set_target_properties(openmw-wizard PROPERTIES COMPILE_FLAGS "${WARNINGS}") - endif() + if (BUILD_LAUNCHER) + set_target_properties(openmw-launcher PROPERTIES COMPILE_FLAGS "${WARNINGS}") + endif() - if (BUILD_UNITTESTS) - set_target_properties(openmw_test_suite PROPERTIES COMPILE_FLAGS "${WARNINGS}") - endif() + if (BUILD_MWINIIMPORTER) + set_target_properties(openmw-iniimporter PROPERTIES COMPILE_FLAGS "${WARNINGS}") + endif() - if (BUILD_BENCHMARKS) - set_target_properties(openmw_detournavigator_navmeshtilescache_benchmark PROPERTIES COMPILE_FLAGS "${WARNINGS}") - endif() + if (BUILD_OPENCS) + set_target_properties(openmw-cs PROPERTIES COMPILE_FLAGS "${WARNINGS}") + endif() - if (BUILD_NAVMESHTOOL) - set_target_properties(openmw-navmeshtool PROPERTIES COMPILE_FLAGS "${WARNINGS}") - endif() + if (BUILD_OPENMW) + set_target_properties(openmw PROPERTIES COMPILE_FLAGS "${WARNINGS}") + endif() - if (BUILD_BULLETOBJECTTOOL) - set(WARNINGS "${WARNINGS} ${MT_BUILD}") - set_target_properties(openmw-bulletobjecttool PROPERTIES COMPILE_FLAGS "${WARNINGS}") - endif() - endif(MSVC) + if (BUILD_WIZARD) + set_target_properties(openmw-wizard PROPERTIES COMPILE_FLAGS "${WARNINGS}") + endif() + + if (BUILD_UNITTESTS) + set_target_properties(openmw_test_suite PROPERTIES COMPILE_FLAGS "${WARNINGS}") + endif() + + if (BUILD_BENCHMARKS) + set_target_properties(openmw_detournavigator_navmeshtilescache_benchmark PROPERTIES COMPILE_FLAGS "${WARNINGS}") + endif() + + if (BUILD_NAVMESHTOOL) + set_target_properties(openmw-navmeshtool PROPERTIES COMPILE_FLAGS "${WARNINGS}") + endif() + + if (BUILD_BULLETOBJECTTOOL) + set(WARNINGS "${WARNINGS} ${MT_BUILD}") + set_target_properties(openmw-bulletobjecttool PROPERTIES COMPILE_FLAGS "${WARNINGS}") + endif() + endif(MSVC) - # 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_MINSIZEREL "/SUBSYSTEM:WINDOWS") + # 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_MINSIZEREL "/SUBSYSTEM:WINDOWS") endif() 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) if (BUILD_OPENCS) - get_property(OPENCS_BUNDLE_NAME_TMP TARGET openmw-cs PROPERTY OUTPUT_NAME) - 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_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) + get_property(OPENCS_BUNDLE_NAME_TMP TARGET openmw-cs PROPERTY OUTPUT_NAME) + 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_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) endif () install(DIRECTORY "${APP_BUNDLE_DIR}" USE_SOURCE_PERMISSIONS DESTINATION "." COMPONENT Runtime) diff --git a/apps/bsatool/CMakeLists.txt b/apps/bsatool/CMakeLists.txt index 058519bba5..aaec225038 100644 --- a/apps/bsatool/CMakeLists.txt +++ b/apps/bsatool/CMakeLists.txt @@ -9,13 +9,13 @@ openmw_add_executable(bsatool ) target_link_libraries(bsatool - ${Boost_PROGRAM_OPTIONS_LIBRARY} - components + ${Boost_PROGRAM_OPTIONS_LIBRARY} + components ) if (BUILD_WITH_CODE_COVERAGE) - add_definitions (--coverage) - target_link_libraries(bsatool gcov) + add_definitions (--coverage) + target_link_libraries(bsatool gcov) endif() if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) diff --git a/apps/esmtool/CMakeLists.txt b/apps/esmtool/CMakeLists.txt index 841fb4b219..1143dece4f 100644 --- a/apps/esmtool/CMakeLists.txt +++ b/apps/esmtool/CMakeLists.txt @@ -1,28 +1,28 @@ set(ESMTOOL - esmtool.cpp - labels.hpp - labels.cpp - record.hpp - record.cpp - arguments.hpp - tes4.hpp - tes4.cpp + esmtool.cpp + labels.hpp + labels.cpp + record.hpp + record.cpp + arguments.hpp + tes4.hpp + tes4.cpp ) source_group(apps\\esmtool FILES ${ESMTOOL}) # Main executable openmw_add_executable(esmtool - ${ESMTOOL} + ${ESMTOOL} ) target_link_libraries(esmtool - ${Boost_PROGRAM_OPTIONS_LIBRARY} - components + ${Boost_PROGRAM_OPTIONS_LIBRARY} + components ) if (BUILD_WITH_CODE_COVERAGE) - add_definitions (--coverage) - target_link_libraries(esmtool gcov) + add_definitions (--coverage) + target_link_libraries(esmtool gcov) endif() if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) diff --git a/apps/essimporter/CMakeLists.txt b/apps/essimporter/CMakeLists.txt index 4d53bc4cb3..bf0fd5e813 100644 --- a/apps/essimporter/CMakeLists.txt +++ b/apps/essimporter/CMakeLists.txt @@ -39,12 +39,12 @@ target_link_libraries(openmw-essimporter ) if (BUILD_WITH_CODE_COVERAGE) - add_definitions (--coverage) - target_link_libraries(openmw-essimporter gcov) + add_definitions (--coverage) + target_link_libraries(openmw-essimporter gcov) endif() if (WIN32) - INSTALL(TARGETS openmw-essimporter RUNTIME DESTINATION ".") + INSTALL(TARGETS openmw-essimporter RUNTIME DESTINATION ".") endif(WIN32) if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index 790c5436f0..1e0f3f9bf7 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -85,8 +85,8 @@ target_link_libraries(openmw-launcher target_link_libraries(openmw-launcher Qt::Widgets Qt::Core) if (BUILD_WITH_CODE_COVERAGE) - add_definitions (--coverage) - target_link_libraries(openmw-launcher gcov) + add_definitions (--coverage) + target_link_libraries(openmw-launcher gcov) endif() if(USE_QT) diff --git a/apps/mwiniimporter/CMakeLists.txt b/apps/mwiniimporter/CMakeLists.txt index 3f767bc6f6..8339db9624 100644 --- a/apps/mwiniimporter/CMakeLists.txt +++ b/apps/mwiniimporter/CMakeLists.txt @@ -25,12 +25,12 @@ if (WIN32) endif(WIN32) if (MINGW) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -municode") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -municode") endif() if (BUILD_WITH_CODE_COVERAGE) - add_definitions (--coverage) - target_link_libraries(openmw-iniimporter gcov) + add_definitions (--coverage) + target_link_libraries(openmw-iniimporter gcov) endif() if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) diff --git a/apps/niftest/CMakeLists.txt b/apps/niftest/CMakeLists.txt index 2f0dcb59e3..18dbf877cb 100644 --- a/apps/niftest/CMakeLists.txt +++ b/apps/niftest/CMakeLists.txt @@ -9,12 +9,12 @@ openmw_add_executable(niftest ) target_link_libraries(niftest - components + components ) if (BUILD_WITH_CODE_COVERAGE) - add_definitions (--coverage) - target_link_libraries(niftest gcov) + add_definitions (--coverage) + target_link_libraries(niftest gcov) endif() if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index ff2ecfe5c9..f330047027 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -192,12 +192,12 @@ if (USE_SYSTEM_TINYXML) endif() if (NOT UNIX) -target_link_libraries(openmw ${SDL2MAIN_LIBRARY}) + target_link_libraries(openmw ${SDL2MAIN_LIBRARY}) endif() # Fix for not visible pthreads functions for linker with glibc 2.15 if (UNIX AND NOT APPLE) -target_link_libraries(openmw ${CMAKE_THREAD_LIBS_INIT}) + target_link_libraries(openmw ${CMAKE_THREAD_LIBS_INIT}) endif() if(APPLE) @@ -230,8 +230,8 @@ if(APPLE) endif(APPLE) if (BUILD_WITH_CODE_COVERAGE) - add_definitions (--coverage) - target_link_libraries(openmw gcov) + add_definitions (--coverage) + target_link_libraries(openmw gcov) endif() if (WIN32) diff --git a/apps/wizard/CMakeLists.txt b/apps/wizard/CMakeLists.txt index 895fe0ee46..d2aef7005a 100644 --- a/apps/wizard/CMakeLists.txt +++ b/apps/wizard/CMakeLists.txt @@ -94,13 +94,13 @@ if(DPKG_PROGRAM) endif() if (BUILD_WITH_CODE_COVERAGE) - add_definitions (--coverage) - target_link_libraries(openmw-wizard gcov) + add_definitions (--coverage) + target_link_libraries(openmw-wizard gcov) endif() # Workaround for binutil => 2.23 problem when linking, should be fixed eventually upstream if (CMAKE_SYSTEM_NAME MATCHES "Linux") -target_link_libraries(openmw-wizard dl Xt) + target_link_libraries(openmw-wizard dl Xt) endif() if (WIN32) diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index a78d8c61cb..7fb9d9f851 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -483,7 +483,7 @@ endif() # Fix for not visible pthreads functions for linker with glibc 2.15 if (UNIX AND NOT APPLE) -target_link_libraries(components ${CMAKE_THREAD_LIBS_INIT}) + target_link_libraries(components ${CMAKE_THREAD_LIBS_INIT}) endif() if (BUILD_WITH_CODE_COVERAGE) From a527db8ca7c53c765c22763e0e2e2df68c66c09b Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 10 Mar 2023 15:07:16 +0100 Subject: [PATCH 3/5] Enforce space only indendation in CMake files --- .gitlab-ci.yml | 1 + CI/check_cmake_format.sh | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100755 CI/check_cmake_format.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3d4a3ee193..5b0d1c18bd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -132,6 +132,7 @@ Clang_Format: before_script: - CI/install_debian_deps.sh openmw-clang-format script: + - CI/check_cmake_format.sh - CI/check_file_names.sh - CI/check_clang_format.sh diff --git a/CI/check_cmake_format.sh b/CI/check_cmake_format.sh new file mode 100755 index 0000000000..40cd0b77f6 --- /dev/null +++ b/CI/check_cmake_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 From 1857d8a68ce6dc256b2be50ba9787d5db55b9710 Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 10 Mar 2023 15:16:09 +0100 Subject: [PATCH 4/5] Use target_compile_options to add --coverage --- apps/bsatool/CMakeLists.txt | 2 +- apps/bulletobjecttool/CMakeLists.txt | 2 +- apps/esmtool/CMakeLists.txt | 2 +- apps/essimporter/CMakeLists.txt | 2 +- apps/launcher/CMakeLists.txt | 2 +- apps/mwiniimporter/CMakeLists.txt | 2 +- apps/navmeshtool/CMakeLists.txt | 2 +- apps/niftest/CMakeLists.txt | 2 +- apps/openmw/CMakeLists.txt | 2 +- apps/openmw_test_suite/CMakeLists.txt | 2 +- apps/wizard/CMakeLists.txt | 2 +- components/CMakeLists.txt | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/apps/bsatool/CMakeLists.txt b/apps/bsatool/CMakeLists.txt index aaec225038..0ee6d8472a 100644 --- a/apps/bsatool/CMakeLists.txt +++ b/apps/bsatool/CMakeLists.txt @@ -14,7 +14,7 @@ target_link_libraries(bsatool ) if (BUILD_WITH_CODE_COVERAGE) - add_definitions (--coverage) + target_compile_options(bsatool PRIVATE --coverage) target_link_libraries(bsatool gcov) endif() diff --git a/apps/bulletobjecttool/CMakeLists.txt b/apps/bulletobjecttool/CMakeLists.txt index bc19a29e21..924f66301c 100644 --- a/apps/bulletobjecttool/CMakeLists.txt +++ b/apps/bulletobjecttool/CMakeLists.txt @@ -11,7 +11,7 @@ target_link_libraries(openmw-bulletobjecttool ) if (BUILD_WITH_CODE_COVERAGE) - add_definitions(--coverage) + target_compile_options(openmw-bulletobjecttool PRIVATE --coverage) target_link_libraries(openmw-bulletobjecttool gcov) endif() diff --git a/apps/esmtool/CMakeLists.txt b/apps/esmtool/CMakeLists.txt index 1143dece4f..ad95b2b8e5 100644 --- a/apps/esmtool/CMakeLists.txt +++ b/apps/esmtool/CMakeLists.txt @@ -21,7 +21,7 @@ target_link_libraries(esmtool ) if (BUILD_WITH_CODE_COVERAGE) - add_definitions (--coverage) + target_compile_options(esmtool PRIVATE --coverage) target_link_libraries(esmtool gcov) endif() diff --git a/apps/essimporter/CMakeLists.txt b/apps/essimporter/CMakeLists.txt index bf0fd5e813..3928d88e8f 100644 --- a/apps/essimporter/CMakeLists.txt +++ b/apps/essimporter/CMakeLists.txt @@ -39,7 +39,7 @@ target_link_libraries(openmw-essimporter ) if (BUILD_WITH_CODE_COVERAGE) - add_definitions (--coverage) + target_compile_options(openmw-essimporter PRIVATE --coverage) target_link_libraries(openmw-essimporter gcov) endif() diff --git a/apps/launcher/CMakeLists.txt b/apps/launcher/CMakeLists.txt index 1e0f3f9bf7..fe27dfc498 100644 --- a/apps/launcher/CMakeLists.txt +++ b/apps/launcher/CMakeLists.txt @@ -85,7 +85,7 @@ target_link_libraries(openmw-launcher target_link_libraries(openmw-launcher Qt::Widgets Qt::Core) if (BUILD_WITH_CODE_COVERAGE) - add_definitions (--coverage) + target_compile_options(openmw-launcher PRIVATE --coverage) target_link_libraries(openmw-launcher gcov) endif() diff --git a/apps/mwiniimporter/CMakeLists.txt b/apps/mwiniimporter/CMakeLists.txt index 8339db9624..d5cd2e6362 100644 --- a/apps/mwiniimporter/CMakeLists.txt +++ b/apps/mwiniimporter/CMakeLists.txt @@ -29,7 +29,7 @@ if (MINGW) endif() if (BUILD_WITH_CODE_COVERAGE) - add_definitions (--coverage) + target_compile_options(openmw-iniimporter PRIVATE --coverage) target_link_libraries(openmw-iniimporter gcov) endif() diff --git a/apps/navmeshtool/CMakeLists.txt b/apps/navmeshtool/CMakeLists.txt index 9f57d52a7e..09d7af3b23 100644 --- a/apps/navmeshtool/CMakeLists.txt +++ b/apps/navmeshtool/CMakeLists.txt @@ -13,7 +13,7 @@ target_link_libraries(openmw-navmeshtool ) if (BUILD_WITH_CODE_COVERAGE) - add_definitions(--coverage) + target_compile_options(openmw-navmeshtool PRIVATE --coverage) target_link_libraries(openmw-navmeshtool gcov) endif() diff --git a/apps/niftest/CMakeLists.txt b/apps/niftest/CMakeLists.txt index 18dbf877cb..5ca21c10c7 100644 --- a/apps/niftest/CMakeLists.txt +++ b/apps/niftest/CMakeLists.txt @@ -13,7 +13,7 @@ target_link_libraries(niftest ) if (BUILD_WITH_CODE_COVERAGE) - add_definitions (--coverage) + target_compile_options(niftest PRIVATE --coverage) target_link_libraries(niftest gcov) endif() diff --git a/apps/openmw/CMakeLists.txt b/apps/openmw/CMakeLists.txt index f330047027..15a6b8713c 100644 --- a/apps/openmw/CMakeLists.txt +++ b/apps/openmw/CMakeLists.txt @@ -230,7 +230,7 @@ if(APPLE) endif(APPLE) if (BUILD_WITH_CODE_COVERAGE) - add_definitions (--coverage) + target_compile_options(openmw PRIVATE --coverage) target_link_libraries(openmw gcov) endif() diff --git a/apps/openmw_test_suite/CMakeLists.txt b/apps/openmw_test_suite/CMakeLists.txt index ae5723cd25..6e7f191eae 100644 --- a/apps/openmw_test_suite/CMakeLists.txt +++ b/apps/openmw_test_suite/CMakeLists.txt @@ -108,7 +108,7 @@ if (UNIX AND NOT APPLE) endif() if (BUILD_WITH_CODE_COVERAGE) - add_definitions(--coverage) + target_compile_options(openmw_test_suite PRIVATE --coverage) target_link_libraries(openmw_test_suite gcov) endif() diff --git a/apps/wizard/CMakeLists.txt b/apps/wizard/CMakeLists.txt index d2aef7005a..588b100ef2 100644 --- a/apps/wizard/CMakeLists.txt +++ b/apps/wizard/CMakeLists.txt @@ -94,7 +94,7 @@ if(DPKG_PROGRAM) endif() if (BUILD_WITH_CODE_COVERAGE) - add_definitions (--coverage) + target_compile_options(openmw-wizard PRIVATE --coverage) target_link_libraries(openmw-wizard gcov) endif() diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 7fb9d9f851..20ef7dfb65 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -487,7 +487,7 @@ if (UNIX AND NOT APPLE) endif() if (BUILD_WITH_CODE_COVERAGE) - add_definitions(--coverage) + target_compile_options(components PRIVATE --coverage) target_link_libraries(components gcov) endif() From 1cc4909144a5041a77ae2ad44ec5b57d356697fd Mon Sep 17 00:00:00 2001 From: elsid Date: Fri, 10 Mar 2023 15:18:45 +0100 Subject: [PATCH 5/5] Add --coverage to components_qt, benchmarks and openmw-cs --- apps/benchmarks/CMakeLists.txt | 5 +++++ apps/opencs/CMakeLists.txt | 5 +++++ components/CMakeLists.txt | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/apps/benchmarks/CMakeLists.txt b/apps/benchmarks/CMakeLists.txt index 095a841742..18bc56ec60 100644 --- a/apps/benchmarks/CMakeLists.txt +++ b/apps/benchmarks/CMakeLists.txt @@ -13,3 +13,8 @@ endif() if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC) target_precompile_headers(openmw_detournavigator_navmeshtilescache_benchmark PRIVATE ) endif() + +if (BUILD_WITH_CODE_COVERAGE) + target_compile_options(openmw_detournavigator_navmeshtilescache_benchmark PRIVATE --coverage) + target_link_libraries(openmw_detournavigator_navmeshtilescache_benchmark gcov) +endif() diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index ab63be0437..a55ba56330 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -260,6 +260,11 @@ if(USE_QT) set_property(TARGET openmw-cs PROPERTY AUTOMOC ON) 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) target_precompile_headers(openmw-cs PRIVATE diff --git a/components/CMakeLists.txt b/components/CMakeLists.txt index 20ef7dfb65..5304086ee7 100644 --- a/components/CMakeLists.txt +++ b/components/CMakeLists.txt @@ -462,6 +462,11 @@ if (USE_QT) add_library(components_qt STATIC ${COMPONENT_QT_FILES} ${ESM_UI_HDR}) target_link_libraries(components_qt components Qt::Widgets Qt::Core) 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() if (GIT_CHECKOUT)