From bb664a1e794860fe86c2bca6d8e92d78fade1dd8 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 16 May 2017 03:30:17 +0200 Subject: cmake: fix makefile dependencies --- cmake/opentrack-boilerplate.cmake | 1 + 1 file changed, 1 insertion(+) (limited to 'cmake/opentrack-boilerplate.cmake') diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake index 3c5bd90a..4c056c3e 100644 --- a/cmake/opentrack-boilerplate.cmake +++ b/cmake/opentrack-boilerplate.cmake @@ -112,6 +112,7 @@ endfunction() function(otr_i18n_for_target_directory n) foreach(i ${opentrack-all-translations}) set(t "${CMAKE_CURRENT_SOURCE_DIR}/lang/${i}.ts") + file(RELATIVE_PATH t "${CMAKE_SOURCE_DIR}" "${t}") 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}" -- cgit v1.2.3 From 6faab6ff960e2dd04aa35e8ef1aa62bce2976725 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 16 May 2017 03:31:00 +0200 Subject: add otr_prop for appending property strings --- cmake/opentrack-boilerplate.cmake | 78 +++++++++++++++++++++++++++++++++++++-- compat/CMakeLists.txt | 2 +- proto-fsuipc/CMakeLists.txt | 2 +- qxt-mini/CMakeLists.txt | 2 +- x-plane-plugin/CMakeLists.txt | 12 +++--- 5 files changed, 84 insertions(+), 12 deletions(-) (limited to 'cmake/opentrack-boilerplate.cmake') diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake index 4c056c3e..bb596951 100644 --- a/cmake/opentrack-boilerplate.cmake +++ b/cmake/opentrack-boilerplate.cmake @@ -75,7 +75,7 @@ endfunction() function(otr_compat target) if(NOT MSVC) - set_property(SOURCE ${${target}-moc} APPEND_STRING PROPERTY COMPILE_FLAGS " -w -Wno-error") + otr_prop(SOURCE ${${target}-moc} COMPILE_FLAGS "-w -Wno-error") endif() if(WIN32) target_link_libraries(${target} dinput8 dxguid strmiids) @@ -97,8 +97,8 @@ function(otr_compat target) 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}") + otr_prop(TARGET ${target} COMPILE_FLAGS "${c-props} ${arg_COMPILE}" + LINK_FLAGS "${l-props} ${arg_LINK}") endfunction() include(CMakeParseArguments) @@ -209,3 +209,75 @@ function(otr_module n_) set_property(GLOBAL APPEND PROPERTY opentrack-all-source-dirs "${CMAKE_CURRENT_SOURCE_DIR}") endfunction() +function(otr_prop type) + set(files "") + set(opts ${ARGN}) + # only SOURCE allows for multiple files + if(".${type}" STREQUAL ".SOURCE") + while(TRUE) + # keep popping first element off `opts' and adding to `files` + list(LENGTH opts len) + if(NOT "${len}" GREATER 0) + break() + endif() + list(GET opts 0 k) + string(FIND "${k}" "." idx1) + string(FIND "${k}" "/" idx2) + if("${idx1}" GREATER -1 AND "${idx2}" GREATER -1) + list(REMOVE_AT opts 0) + list(APPEND files "${k}") + else() + # not a pathname + break() + endif() + endwhile() + # no files, break early + # happens a few in the codebase + list(LENGTH files len) + if(len EQUAL 0) + return() + endif() + else() + # single file argument + set(opts "${ARGN}") + list(GET opts 0 files) + list(REMOVE_AT opts 0) + endif() + # must pass some properties at least + list(LENGTH opts len) + if(NOT "${len}" GREATER 1) + message(FATAL_ERROR "no properties given") + endif() + + # prop name but no value + list(LENGTH opts len) + math(EXPR mod "${len} % 2") + if(NOT "${mod}" EQUAL 0) + message(FATAL_ERROR "must specify parameter for each property") + endif() + + foreach(f ${files}) + set(opts-copy "${opts}") + + while(TRUE) + list(LENGTH opts-copy len) + if ("${len}" LESS 2) + break() + endif() + + # pop off two elements, set property + list(GET opts-copy 0 name) + list(GET opts-copy 1 value) + list(REMOVE_AT opts-copy 1 0) + + get_property(old "${type}" "${f}" PROPERTY "${name}") + if(".${old}" STREQUAL ".") + set(spc "") + else() + set(spc " ") + endif() + + set_property("${type}" "${f}" APPEND_STRING PROPERTY "${name}" "${spc}${value}") + endwhile() + endforeach() +endfunction() diff --git a/compat/CMakeLists.txt b/compat/CMakeLists.txt index 7655a223..33cb02bd 100644 --- a/compat/CMakeLists.txt +++ b/compat/CMakeLists.txt @@ -5,5 +5,5 @@ if(NOT WIN32 AND NOT APPLE) endif() if(CMAKE_COMPILER_IS_GNUCXX) - set_property(SOURCE nan.cpp APPEND_STRING PROPERTY COMPILE_FLAGS " -fno-lto -fno-fast-math -fno-finite-math-only -O0") + otr_prop(SOURCE nan.cpp COMPILE_FLAGS "-fno-lto -fno-fast-math -fno-finite-math-only -O0") endif() diff --git a/proto-fsuipc/CMakeLists.txt b/proto-fsuipc/CMakeLists.txt index 24006644..99e362aa 100644 --- a/proto-fsuipc/CMakeLists.txt +++ b/proto-fsuipc/CMakeLists.txt @@ -5,7 +5,7 @@ if(WIN32) target_link_libraries(opentrack-proto-fsuipc ${SDK_FSUIPC}/FSUIPC_User.lib) target_include_directories(opentrack-proto-fsuipc SYSTEM PUBLIC ${SDK_FSUIPC}) if(MSVC) - set_property(TARGET opentrack-proto-fsuipc APPEND_STRING PROPERTY LINK_FLAGS " /NODEFAULTLIB:LIBC.lib") + otr_prop(TARGET opentrack-proto-fsuipc LINK_FLAGS "/NODEFAULTLIB:LIBC.lib") endif() endif() endif() diff --git a/qxt-mini/CMakeLists.txt b/qxt-mini/CMakeLists.txt index bf8a30f9..a6c2908e 100644 --- a/qxt-mini/CMakeLists.txt +++ b/qxt-mini/CMakeLists.txt @@ -3,6 +3,6 @@ if(UNIX OR APPLE) if(NOT APPLE) target_link_libraries(opentrack-qxt-mini X11) else() - set_property(TARGET opentrack-qxt-mini APPEND_STRING PROPERTY LINK_FLAGS " -framework Carbon -framework CoreFoundation") + otr_prop(TARGET opentrack-qxt-mini LINK_FLAGS "-framework Carbon -framework CoreFoundation") endif() endif() diff --git a/x-plane-plugin/CMakeLists.txt b/x-plane-plugin/CMakeLists.txt index abca2d68..db712590 100644 --- a/x-plane-plugin/CMakeLists.txt +++ b/x-plane-plugin/CMakeLists.txt @@ -7,18 +7,18 @@ if(LINUX OR APPLE) install(FILES ${opentrack-xplane-plugin-c} DESTINATION "${opentrack-doc-src-pfx}/opentrack-xplane-plugin") target_include_directories(opentrack-xplane-plugin SYSTEM PUBLIC ${SDK_XPLANE}/CHeaders ${SDK_XPLANE}/CHeaders/XPLM) - set(begin TARGET opentrack-xplane-plugin APPEND_STRING PROPERTY) + set(begin TARGET opentrack-xplane-plugin) if(APPLE) - set_property(${begin} COMPILE_FLAGS "-iframework ${SDK_XPLANE}/Libraries/Mac/ -DAPL -DXPLM200 -DXPLM210 -framework XPLM -framework XPWidgets") - set_property(${begin} LINK_FLAGS "-F${SDK_XPLANE}/Libraries/Mac/ -framework XPLM -framework XPWidgets") + otr_prop(${begin} COMPILE_FLAGS "-iframework ${SDK_XPLANE}/Libraries/Mac/ -DAPL -DXPLM200 -DXPLM210 -framework XPLM -framework XPWidgets" + LINK_FLAGS "-F${SDK_XPLANE}/Libraries/Mac/ -framework XPLM -framework XPWidgets") elseif(CMAKE_COMPILER_IS_GNUCXX) - set_property(${begin} COMPILE_FLAGS "-fPIC -DLIN -DXPLM200 -DXPLM210") - set_property(${begin} LINK_FLAGS "-rdynamic -nodefaultlibs -fPIC") + otr_prop(${begin} COMPILE_FLAGS "-fPIC -DLIN -DXPLM200 -DXPLM210" + LINK_FLAGS "-rdynamic -nodefaultlibs -fPIC") endif() if(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_COMPILER_IS_CLANG) - set_property(${begin} LINK_FLAGS "-undefined_warning") + otr_prop(${begin} LINK_FLAGS "-undefined_warning") endif() set_target_properties(opentrack-xplane-plugin PROPERTIES -- cgit v1.2.3 From df567396803d3ea57de48fe090cbb9360abde703 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 16 May 2017 05:02:31 +0200 Subject: nothing --- bin/build-msvc.cmd | 2 +- cmake/opentrack-boilerplate.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'cmake/opentrack-boilerplate.cmake') diff --git a/bin/build-msvc.cmd b/bin/build-msvc.cmd index 3b7e4ea0..4adad019 100644 --- a/bin/build-msvc.cmd +++ b/bin/build-msvc.cmd @@ -8,7 +8,7 @@ taskkill -f -im trackir.exe 2>%SystemDrive%\NUL call:check cmake . call:check ninja i18n call:check "d:/cygwin64/bin/dash.exe" -c "git checkout -f -- ../*/lang/ ../*/*/lang/" -call:check ninja -j4 install +call:check ninja -j6 install call:check "d:/cygwin64/bin/dash.exe" -c "git checkout -f -- ../*/lang/ ../*/*/lang/" exit /b 0 diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake index bb596951..6d83e49a 100644 --- a/cmake/opentrack-boilerplate.cmake +++ b/cmake/opentrack-boilerplate.cmake @@ -245,7 +245,7 @@ function(otr_prop type) endif() # must pass some properties at least list(LENGTH opts len) - if(NOT "${len}" GREATER 1) + if(NOT "${len}" GREATER 0) message(FATAL_ERROR "no properties given") endif() -- cgit v1.2.3 From a9ddb1242181032c549bcac7341e38cb2ee0bb73 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 16 May 2017 10:02:37 +0200 Subject: cmake: fix i18n target dependencies The real error was on the "DEPENDS" like in boilerplate.cmake. The rest is merely removing dead code. --- cmake/opentrack-boilerplate.cmake | 5 ++--- cmake/opentrack-install.cmake | 15 ++++----------- 2 files changed, 6 insertions(+), 14 deletions(-) (limited to 'cmake/opentrack-boilerplate.cmake') diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake index 6d83e49a..ec1946f0 100644 --- a/cmake/opentrack-boilerplate.cmake +++ b/cmake/opentrack-boilerplate.cmake @@ -110,18 +110,17 @@ function(otr_install_pdb_current_project target) endfunction() function(otr_i18n_for_target_directory n) + set(k "opentrack-${n}") foreach(i ${opentrack-all-translations}) set(t "${CMAKE_CURRENT_SOURCE_DIR}/lang/${i}.ts") - file(RELATIVE_PATH t "${CMAKE_SOURCE_DIR}" "${t}") 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} + DEPENDS ${${k}-cc} ${${k}-hh} ${${k}-ui} ${${k}-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() diff --git a/cmake/opentrack-install.cmake b/cmake/opentrack-install.cmake index e0d73d5f..2f91ab55 100644 --- a/cmake/opentrack-install.cmake +++ b/cmake/opentrack-install.cmake @@ -50,12 +50,10 @@ otr_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/AUTHORS.md") function(merge_translations) install(CODE "file(REMOVE_RECURSE \"\${CMAKE_INSTALL_PREFIX}/i18n\")") - set(all-ts-files "") set(all-qm-files "") foreach(i ${opentrack-all-translations}) get_property(ts-files GLOBAL PROPERTY "opentrack-ts-files-${i}") - #get_property(ts-deps GLOBAL PROPERTY "opentrack-ts-targets-${i}") set(ts-files_ "") @@ -67,25 +65,20 @@ function(merge_translations) set(ts-files "${ts-files_}") - foreach(k ${ts-files}) - list(APPEND all-ts-files "${k}") - endforeach() - if(NOT ".${ts-files}" STREQUAL ".") - set(lrelease-deps "${ts-files}") - set(qm-output "${CMAKE_CURRENT_BINARY_DIR}/${i}.qm") list(APPEND all-qm-files "${qm-output}") add_custom_command(OUTPUT "${qm-output}" COMMAND "${Qt5_DIR}/../../../bin/lrelease" -nounfinished -silent ${ts-files} -qm "${qm-output}" - DEPENDS ${lrelease-deps} - COMMENT "Running lrelease for ${i}") + DEPENDS ${ts-files} + COMMENT "Running lrelease for ${i}" + ) set(lang-target "i18n-lang-${i}") + add_custom_target("${lang-target}" DEPENDS "${qm-output}") install(FILES "${qm-output}" DESTINATION "${opentrack-i18n-pfx}" RENAME "${i}.qm" ${opentrack-perms}) endif() endforeach() add_custom_target(i18n ALL DEPENDS ${all-qm-files}) - add_custom_target(force-i18n DEPENDS ${all-ts-files} ${all-qm-files} i18n) endfunction() -- cgit v1.2.3