diff options
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/opentrack-boilerplate.cmake | 137 | ||||
-rw-r--r-- | cmake/opentrack-hier.cmake | 1 |
2 files changed, 57 insertions, 81 deletions
diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake index 11e5c71d..da2737af 100644 --- a/cmake/opentrack-boilerplate.cmake +++ b/cmake/opentrack-boilerplate.cmake @@ -81,64 +81,73 @@ function(otr_compat target) target_link_libraries(${target} dinput8 dxguid strmiids) endif() otr_fixup_subsystem(${target}) + + set(c-props) + set(l-props) + if(CMAKE_COMPILER_IS_GNUCXX) + set(c-props "-fvisibility=hidden") + if(NOT is-c-only) + set(c-props "${c-props} -fuse-cxa-atexit") + endif() + endif() + + if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) + set(l-props "-Wl,--as-needed") + endif() + + set_property(TARGET ${target} APPEND_STRING PROPERTY COMPILE_FLAGS "${c-props} ${arg_COMPILE}") + set_property(TARGET ${target} APPEND_STRING PROPERTY LINK_FLAGS "${l-props} ${arg_LINK}") endfunction() include(CMakeParseArguments) -function(otr_is_target_c_only ret srcs) - set(val TRUE) - foreach(i ${srcs}) - get_filename_component(ext "${i}" EXT) - string(TOLOWER "${ext}" ext) - if(ext STREQUAL ".cpp") - set(val FALSE) - break() - endif() - endforeach() - set(${ret} "${val}" PARENT_SCOPE) +function(otr_install_pdb_current_project target) + if(MSVC) + install(FILES "$<TARGET_PDB_FILE:${target}>" DESTINATION "${opentrack-hier-debug}" ${opentrack-perms}) + endif() endfunction() -function(otr_install_pdb_current_project) - if(MSVC AND FALSE) - file(GLOB_RECURSE pdbs "${CMAKE_CURRENT_BINARY_DIR}/*.pdb") - install(FILES ${pdbs} DESTINATION "${subdir}" ${opentrack-perms}) - endif() +function(otr_i18n_for_target_directory n) + foreach(i ${opentrack-all-translations}) + set(t "${CMAKE_CURRENT_SOURCE_DIR}/lang/${i}.ts") + add_custom_command(OUTPUT "${t}" + COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_SOURCE_DIR}/lang" + COMMAND "${Qt5_DIR}/../../../bin/lupdate" -silent -recursive -no-obsolete -locations relative . -ts "${t}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" + DEPENDS ${${n}-cc} ${${n}-hh} ${${n}-ui} ${${n}-rc} + COMMENT "Running lupdate for ${n}/${i}") + set(target-name "i18n-lang-${i}-module-${n}") + add_custom_target(${target-name} DEPENDS "${t}") + set_property(GLOBAL APPEND PROPERTY "opentrack-ts-targets-${i}" "${target-name}") + set_property(GLOBAL APPEND PROPERTY "opentrack-ts-files-${i}" "${t}") + endforeach() endfunction() -function(otr_module n) - message(STATUS "module ${n}") +function(otr_module n_) + message(STATUS "module ${n_}") cmake_parse_arguments(arg "STATIC;NO-COMPAT;BIN;EXECUTABLE;NO-QT;WIN32-CONSOLE;NO-INSTALL" "LINK;COMPILE" "SOURCES" ${ARGN} - ) + ) if(NOT "${arg_UNPARSED_ARGUMENTS}" STREQUAL "") message(FATAL_ERROR "otr_module bad formals: ${arg_UNPARSED_ARGUMENTS}") endif() - set(n_orig "${n}") - set(n "opentrack-${n}") + set(n "opentrack-${n_}") otr_glob_sources(${n}) - otr_is_target_c_only(is-c-only "${${n}-all}") - if(NOT (is-c-only OR arg_NO-QT)) - otr_qt(${n}) - else() - set(arg_NO-QT TRUE) - endif() list(APPEND ${n}-all ${arg_SOURCES}) - if(arg_NO-QT) + if(NOT arg_NO-QT) + otr_qt(${n}) + else() set(arg_NO-COMPAT TRUE) endif() - string(TOUPPER arg_WIN32-CONSOLE "${arg_WIN32-CONSOLE}") - if(NOT WIN32) set(subsys "") - elseif(MSVC) - set(subsys "WIN32") elseif(arg_WIN32-CONSOLE) set(subsys "") else() @@ -154,7 +163,6 @@ function(otr_module n) endif() add_library(${n} ${link-mode} "${${n}-all}") endif() - set_property(TARGET ${n} PROPERTY PREFIX "") if(NOT arg_NO-QT) target_link_libraries(${n} ${MY_QT_LIBS}) @@ -164,60 +172,27 @@ function(otr_module n) target_link_libraries(${n} opentrack-api opentrack-options opentrack-compat) endif() - otr_compat(${n}) + string(REPLACE "-" "_" build-n ${n_}) + string(TOUPPER "${build-n}" build-n) + target_compile_definitions(${n} PRIVATE "BUILD_${build-n}") - if(CMAKE_COMPILER_IS_GNUCXX) - set(c-props "-fvisibility=hidden") - if(NOT is-c-only) - set(c-props "${c-props} -fuse-cxa-atexit") - endif() + if(arg_STATIC) + set(arg_NO-INSTALL TRUE) endif() - if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE) - set(l-props "-Wl,--as-needed") - endif() - - set_property(TARGET ${n} APPEND_STRING PROPERTY COMPILE_FLAGS "${c-props} ${arg_COMPILE}") - set_property(TARGET ${n} APPEND_STRING PROPERTY LINK_FLAGS "${l-props} ${arg_LINK}") - - if(NOT arg_STATIC) - string(REGEX REPLACE "^opentrack-" "" n_ "${n}") - string(REPLACE "-" "_" n_ ${n_}) - string(TOUPPER "${n_}" n__) - target_compile_definitions(${n} PRIVATE "BUILD_${n__}") - - if(NOT arg_NO-INSTALL) - if(arg_BIN AND WIN32) - set(subdir ".") - install(TARGETS "${n}" RUNTIME DESTINATION . ${opentrack-perms}) - else() - set(subdir "${opentrack-hier-pfx}") - install(TARGETS "${n}" ${opentrack-hier-str} ${opentrack-perms}) - endif() - otr_install_pdb_current_project() + if(NOT arg_NO-INSTALL) + if(arg_BIN AND WIN32) + install(TARGETS "${n}" RUNTIME DESTINATION . ${opentrack-perms}) + else() + install(TARGETS "${n}" ${opentrack-hier-str} ${opentrack-perms}) endif() - else() - target_compile_definitions(${n} PRIVATE "STATIC_LIBRARY=1") + otr_install_pdb_current_project(${n}) endif() - set_property(GLOBAL APPEND PROPERTY opentrack-all-modules "${n}") - - foreach(i ${opentrack-all-translations}) - set(t "${CMAKE_CURRENT_SOURCE_DIR}/lang/${i}.ts") - add_custom_command(OUTPUT "${t}" - COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_SOURCE_DIR}/lang" - COMMAND "${Qt5_DIR}/../../../bin/lupdate" -silent -recursive -no-obsolete -locations relative . -ts "${t}" - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" - DEPENDS ${${n}-cc} ${${n}-hh} ${${n}-ui} ${${n}-rc} - COMMENT "Running lupdate for ${n}/${i}") - set(target-name "i18n-lang-${i}-module-${n_orig}") - add_custom_target(${target-name} DEPENDS "${t}") - set_property(GLOBAL APPEND PROPERTY "opentrack-ts-targets-${i}" "${target-name}") - set_property(GLOBAL APPEND PROPERTY "opentrack-ts-files-${i}" "${t}") - endforeach() + otr_compat(${n}) + otr_i18n_for_target_directory(${n_}) - if(NOT arg_NO-INSTALL) - set_property(GLOBAL APPEND PROPERTY opentrack-all-source-dirs "${CMAKE_CURRENT_SOURCE_DIR}") - endif() + set_property(GLOBAL APPEND PROPERTY opentrack-all-modules "${n}") + set_property(GLOBAL APPEND PROPERTY opentrack-all-source-dirs "${CMAKE_CURRENT_SOURCE_DIR}") endfunction() diff --git a/cmake/opentrack-hier.cmake b/cmake/opentrack-hier.cmake index 905625fb..c81ebdd3 100644 --- a/cmake/opentrack-hier.cmake +++ b/cmake/opentrack-hier.cmake @@ -26,6 +26,7 @@ elseif(WIN32) set(opentrack-hier-str RUNTIME DESTINATION ./modules/ LIBRARY DESTINATION ./modules/)
set(opentrack-i18n-pfx "./i18n")
set(opentrack-i18n-path "./i18n")
+ set(opentrack-hier-debug "./debug")
else()
set(opentrack-hier-pfx "libexec/opentrack")
set(opentrack-hier-path "/../libexec/opentrack/")
|