summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-05-16 03:31:00 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-05-16 03:31:00 +0200
commit6faab6ff960e2dd04aa35e8ef1aa62bce2976725 (patch)
treee23afb50b7091cb15b00a37020a7080be352fa83
parentbb664a1e794860fe86c2bca6d8e92d78fade1dd8 (diff)
add otr_prop for appending property strings
-rw-r--r--cmake/opentrack-boilerplate.cmake78
-rw-r--r--compat/CMakeLists.txt2
-rw-r--r--proto-fsuipc/CMakeLists.txt2
-rw-r--r--qxt-mini/CMakeLists.txt2
-rw-r--r--x-plane-plugin/CMakeLists.txt12
5 files changed, 84 insertions, 12 deletions
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