diff options
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/opentrack-boilerplate.cmake | 35 | ||||
-rw-r--r-- | cmake/opentrack-hier.cmake | 99 | ||||
-rw-r--r-- | cmake/opentrack-install.cmake | 38 | ||||
-rw-r--r-- | cmake/opentrack-platform.cmake | 4 | ||||
-rw-r--r-- | cmake/opentrack-qt.cmake | 2 | ||||
-rw-r--r-- | cmake/opentrack-rift.cmake | 75 | ||||
-rw-r--r-- | cmake/opentrack-version.cmake | 2 |
7 files changed, 126 insertions, 129 deletions
diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake index 32829279..5661e151 100644 --- a/cmake/opentrack-boilerplate.cmake +++ b/cmake/opentrack-boilerplate.cmake @@ -19,14 +19,14 @@ set(new-hier-path "#pragma once set(hier-path-filename "${CMAKE_BINARY_DIR}/opentrack-library-path.h") set(orig-hier-path "") -if(EXISTS ${hier-path-filename}) +if(EXISTS "${hier-path-filename}") file(READ ${hier-path-filename} orig-hier-path) endif() if(NOT (orig-hier-path STREQUAL new-hier-path)) - file(WRITE ${hier-path-filename} "${new-hier-path}") + file(WRITE "${hier-path-filename}" "${new-hier-path}") endif() -function(opentrack_glob_sources var) +function(otr_glob_sources var) set(dir "${CMAKE_CURRENT_SOURCE_DIR}") file(GLOB ${var}-c ${dir}/*.cpp ${dir}/*.c ${dir}/*.h ${dir}/*.hpp) file(GLOB ${var}-res ${dir}/*.rc) @@ -41,7 +41,7 @@ function(opentrack_glob_sources var) endforeach() endfunction() -function(opentrack_qt n) +function(otr_qt n) qt5_wrap_cpp(${n}-moc ${${n}-c} OPTIONS --no-notes) qt5_wrap_ui(${n}-uih ${${n}-ui}) qt5_add_resources(${n}-rcc ${${n}-rc}) @@ -52,7 +52,7 @@ function(opentrack_qt n) set(${n}-all "${${n}-all}" PARENT_SCOPE) endfunction() -function(opentrack_fixup_subsystem n) +function(otr_fixup_subsystem n) if(MSVC) if(SDK_CONSOLE_DEBUG) set(subsystem CONSOLE) @@ -69,19 +69,19 @@ function(opentrack_fixup_subsystem n) endif() endfunction() -function(opentrack_compat target) +function(otr_compat target) if(NOT MSVC) set_property(SOURCE ${${target}-moc} APPEND_STRING PROPERTY COMPILE_FLAGS "-w -Wno-error") endif() if(WIN32) target_link_libraries(${target} dinput8 dxguid strmiids) endif() - opentrack_fixup_subsystem(${target}) + otr_fixup_subsystem(${target}) endfunction() include(CMakeParseArguments) -function(opentrack_is_target_c_only ret srcs) +function(otr_is_target_c_only ret srcs) set(val TRUE) foreach(i ${srcs}) get_filename_component(ext "${i}" EXT) @@ -94,14 +94,14 @@ function(opentrack_is_target_c_only ret srcs) set(${ret} "${val}" PARENT_SCOPE) endfunction() -function(opentrack_install_pdb_current_project) +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() endfunction() -function(opentrack_boilerplate n) +function(otr_module n) message(STATUS "module ${n}") cmake_parse_arguments(arg "STATIC;NO-COMPAT;BIN;EXECUTABLE;NO-QT;WIN32-CONSOLE;NO-INSTALL" @@ -110,14 +110,16 @@ function(opentrack_boilerplate n) ${ARGN} ) if(NOT "${arg_UNPARSED_ARGUMENTS}" STREQUAL "") - message(FATAL_ERROR "opentrack_boilerplate bad formals: ${arg_UNPARSED_ARGUMENTS}") + message(FATAL_ERROR "otr_module bad formals: ${arg_UNPARSED_ARGUMENTS}") endif() + set(n "opentrack-${n}") + project(${n}) - opentrack_glob_sources(${n}) - opentrack_is_target_c_only(is-c-only "${${n}-all}") + otr_glob_sources(${n}) + otr_is_target_c_only(is-c-only "${${n}-all}") if(NOT (is-c-only OR arg_NO-QT)) - opentrack_qt(${n}) + otr_qt(${n}) else() set(arg_NO-QT TRUE) endif() @@ -148,6 +150,7 @@ function(opentrack_boilerplate 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}) @@ -157,7 +160,7 @@ function(opentrack_boilerplate n) target_link_libraries(${n} opentrack-api opentrack-options opentrack-compat) endif() - opentrack_compat(${n}) + otr_compat(${n}) if(CMAKE_COMPILER_IS_GNUCXX) set(c-props "-fvisibility=hidden") @@ -186,7 +189,7 @@ function(opentrack_boilerplate n) set(subdir "${opentrack-hier-pfx}") install(TARGETS "${n}" ${opentrack-hier-str} ${opentrack-perms}) endif() - opentrack_install_pdb_current_project() + otr_install_pdb_current_project() endif() endif() diff --git a/cmake/opentrack-hier.cmake b/cmake/opentrack-hier.cmake index a892311c..905625fb 100644 --- a/cmake/opentrack-hier.cmake +++ b/cmake/opentrack-hier.cmake @@ -7,59 +7,56 @@ # TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
-if(NOT opentrack-hier-included)
- set(opentrack-hier-included TRUE)
- set(opentrack-install-rpath "")
- if(APPLE)
- set(opentrack-hier-pfx ".")
- set(opentrack-hier-path "/")
- set(opentrack-hier-doc "/")
- set(opentrack-hier-str RUNTIME DESTINATION . LIBRARY DESTINATION .)
- set(opentrack-doc-pfx "./doc")
- set(opentrack-doc-src-pfx "./source-code")
- set(opentrack-i18n-pfx "./i18n")
- set(opentrack-i18n-path "./i18n")
- elseif(WIN32)
- set(opentrack-hier-pfx "./modules")
- set(opentrack-hier-path "/modules/")
- set(opentrack-hier-doc "/doc/")
- set(opentrack-doc-pfx "./doc")
- set(opentrack-doc-src-pfx "./source-code")
- set(opentrack-hier-str RUNTIME DESTINATION ./modules/ LIBRARY DESTINATION ./modules/)
- set(opentrack-i18n-pfx "./i18n")
- set(opentrack-i18n-path "./i18n")
- else()
- set(opentrack-hier-pfx "libexec/opentrack")
- set(opentrack-hier-path "/../libexec/opentrack/")
- set(opentrack-hier-doc "/share/doc/opentrack/")
- set(opentrack-doc-pfx "./share/doc/opentrack")
- set(opentrack-doc-src-pfx "./share/doc/opentrack/source-code")
- set(opentrack-install-rpath "${CMAKE_INSTALL_PREFIX}/${opentrack-hier-pfx}")
- set(opentrack-hier-str ARCHIVE DESTINATION lib/opentrack LIBRARY DESTINATION ${opentrack-hier-pfx} RUNTIME DESTINATION bin)
- set(opentrack-i18n-pfx "./libexec/opentrack/i18n")
- set(opentrack-i18n-path "../libexec/opentrack/i18n")
- endif()
+set(opentrack-install-rpath "")
+if(APPLE)
+ set(opentrack-hier-pfx ".")
+ set(opentrack-hier-path "/")
+ set(opentrack-hier-doc "/")
+ set(opentrack-hier-str RUNTIME DESTINATION . LIBRARY DESTINATION .)
+ set(opentrack-doc-pfx "./doc")
+ set(opentrack-doc-src-pfx "./source-code")
+ set(opentrack-i18n-pfx "./i18n")
+ set(opentrack-i18n-path "./i18n")
+elseif(WIN32)
+ set(opentrack-hier-pfx "./modules")
+ set(opentrack-hier-path "/modules/")
+ set(opentrack-hier-doc "/doc/")
+ set(opentrack-doc-pfx "./doc")
+ set(opentrack-doc-src-pfx "./source-code")
+ set(opentrack-hier-str RUNTIME DESTINATION ./modules/ LIBRARY DESTINATION ./modules/)
+ set(opentrack-i18n-pfx "./i18n")
+ set(opentrack-i18n-path "./i18n")
+else()
+ set(opentrack-hier-pfx "libexec/opentrack")
+ set(opentrack-hier-path "/../libexec/opentrack/")
+ set(opentrack-hier-doc "/share/doc/opentrack/")
+ set(opentrack-doc-pfx "./share/doc/opentrack")
+ set(opentrack-doc-src-pfx "./share/doc/opentrack/source-code")
+ set(opentrack-install-rpath "${CMAKE_INSTALL_PREFIX}/${opentrack-hier-pfx}")
+ set(opentrack-hier-str ARCHIVE DESTINATION lib/opentrack LIBRARY DESTINATION ${opentrack-hier-pfx} RUNTIME DESTINATION bin)
+ set(opentrack-i18n-pfx "./libexec/opentrack/i18n")
+ set(opentrack-i18n-path "../libexec/opentrack/i18n")
+endif()
- function(opentrack_escape_string var str)
- string(REGEX REPLACE "([\$\\\"#])" "\\\\\\1" tmp__ "${str}")
- set(${var} "${tmp__}" PARENT_SCOPE)
- endfunction()
+function(otr_escape_string var str)
+ string(REGEX REPLACE "([\$\\\"#])" "\\\\\\1" tmp__ "${str}")
+ set(${var} "${tmp__}" PARENT_SCOPE)
+endfunction()
- function(opentrack_setup_refresh_install_dir)
- if((NOT CMAKE_INSTALL_PREFIX STREQUAL "") AND (NOT opentrack-doc-src-pfx STREQUAL ""))
- opentrack_escape_string(dir "${CMAKE_INSTALL_PREFIX}/${opentrack-doc-src-pfx}/")
- install(CODE "file(REMOVE_RECURSE \"${dir}\")")
- endif()
- endfunction()
+function(otr_setup_refresh_install_dir)
+ if((NOT CMAKE_INSTALL_PREFIX STREQUAL "") AND (NOT opentrack-doc-src-pfx STREQUAL ""))
+ otr_escape_string(dir "${CMAKE_INSTALL_PREFIX}/${opentrack-doc-src-pfx}/")
+ install(CODE "file(REMOVE_RECURSE \"${dir}\")")
+ endif()
+endfunction()
- opentrack_setup_refresh_install_dir()
+otr_setup_refresh_install_dir()
- set(opentrack-contrib-pfx "${opentrack-doc-pfx}/contrib")
+set(opentrack-contrib-pfx "${opentrack-doc-pfx}/contrib")
- set(opentrack-binary-suffix "")
- if(APPLE)
- set(opentrack-binary-suffix ".bin")
- elseif(WIN32)
- set(opentrack-binary-suffix ".exe")
- endif()
-endif() # include guard
+set(opentrack-binary-suffix "")
+if(APPLE)
+ set(opentrack-binary-suffix ".bin")
+elseif(WIN32)
+ set(opentrack-binary-suffix ".exe")
+endif()
diff --git a/cmake/opentrack-install.cmake b/cmake/opentrack-install.cmake index e4f3b2b2..92250bb2 100644 --- a/cmake/opentrack-install.cmake +++ b/cmake/opentrack-install.cmake @@ -1,11 +1,11 @@ set(opentrack-perms_ WORLD_READ WORLD_EXECUTE OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE) set(opentrack-perms PERMISSIONS ${opentrack-perms_}) -macro(opentrack_inst2 path) +macro(otr_inst2 path) install(${ARGN} DESTINATION "${path}" ${opentrack-perms}) endmacro() -macro(opentrack_inst_dir path) +macro(otr_inst_dir path) install( DIRECTORY ${ARGN} DESTINATION "${path}" FILE_PERMISSIONS ${opentrack-perms_} @@ -17,35 +17,35 @@ function(install_sources) get_property(source-dirs GLOBAL PROPERTY opentrack-all-source-dirs) foreach(k ${source-dirs}) file(RELATIVE_PATH dest "${CMAKE_SOURCE_DIR}" "${k}") - opentrack_inst_dir("${opentrack-doc-src-pfx}" "${dest}") + otr_inst_dir("${opentrack-doc-src-pfx}" "${dest}") endforeach() endfunction() -opentrack_inst_dir("${opentrack-doc-pfx}" ${CMAKE_SOURCE_DIR}/3rdparty-notices) -opentrack_inst_dir("${opentrack-doc-pfx}" "${CMAKE_SOURCE_DIR}/settings" "${CMAKE_SOURCE_DIR}/contrib") -opentrack_inst_dir("${opentrack-doc-src-pfx}" "${CMAKE_SOURCE_DIR}/cmake") -opentrack_inst_dir("${opentrack-doc-src-pfx}" "${CMAKE_SOURCE_DIR}/bin") +otr_inst_dir("${opentrack-doc-pfx}" ${CMAKE_SOURCE_DIR}/3rdparty-notices) +otr_inst_dir("${opentrack-doc-pfx}" "${CMAKE_SOURCE_DIR}/settings" "${CMAKE_SOURCE_DIR}/contrib") +otr_inst_dir("${opentrack-doc-src-pfx}" "${CMAKE_SOURCE_DIR}/cmake") +otr_inst_dir("${opentrack-doc-src-pfx}" "${CMAKE_SOURCE_DIR}/bin") if(WIN32) - opentrack_inst2(. FILES "${CMAKE_SOURCE_DIR}/bin/qt.conf") - opentrack_inst2(. FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config") - opentrack_inst2(${opentrack-hier-pfx} FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config") + otr_inst2(. FILES "${CMAKE_SOURCE_DIR}/bin/qt.conf") + otr_inst2(. FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config") + otr_inst2(${opentrack-hier-pfx} FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config") endif() -opentrack_inst2("${opentrack-doc-pfx}" FILES ${CMAKE_SOURCE_DIR}/README.md) +otr_inst2("${opentrack-doc-pfx}" FILES ${CMAKE_SOURCE_DIR}/README.md) -opentrack_inst2("${opentrack-hier-pfx}" FILES "${CMAKE_SOURCE_DIR}/bin/freetrackclient.dll") -opentrack_inst2("${opentrack-hier-pfx}" FILES +otr_inst2("${opentrack-hier-pfx}" FILES "${CMAKE_SOURCE_DIR}/bin/freetrackclient.dll") +otr_inst2("${opentrack-hier-pfx}" FILES "${CMAKE_SOURCE_DIR}/bin/NPClient.dll" "${CMAKE_SOURCE_DIR}/bin/NPClient64.dll" "${CMAKE_SOURCE_DIR}/bin/TrackIR.exe") -opentrack_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/CMakeLists.txt") -opentrack_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/README.md") -opentrack_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/CONTRIBUTING.md") -opentrack_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/WARRANTY.txt") -opentrack_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/OPENTRACK-LICENSING.txt") -opentrack_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/AUTHORS.md") +otr_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/CMakeLists.txt") +otr_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/README.md") +otr_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/CONTRIBUTING.md") +otr_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/WARRANTY.txt") +otr_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/OPENTRACK-LICENSING.txt") +otr_inst2("${opentrack-doc-src-pfx}" FILES "${CMAKE_SOURCE_DIR}/AUTHORS.md") function(merge_translations) set(all-deps "") diff --git a/cmake/opentrack-platform.cmake b/cmake/opentrack-platform.cmake index 721d5675..ab3a5f8b 100644 --- a/cmake/opentrack-platform.cmake +++ b/cmake/opentrack-platform.cmake @@ -74,7 +74,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC OFF) set(CMAKE_POSITION_INDEPENDENT_CODE ON) -include_directories(${CMAKE_SOURCE_DIR}) +include_directories("${CMAKE_SOURCE_DIR}") if(APPLE) set(CMAKE_MACOSX_RPATH OFF) @@ -105,7 +105,7 @@ function(fix_flags lang flag replacement) if(".${replacement}" STREQUAL ".") set(pfx "") endif() - opentrack_escape_string(flag "${flag}") + otr_escape_string(flag "${flag}") foreach(k _DEBUG _RELEASE _MINSIZEREL _RELWITHDEBINFO "") set(tmp "${CMAKE_${lang}_FLAGS${k}}") if(NOT ".${replacement}" STREQUAL ".") diff --git a/cmake/opentrack-qt.cmake b/cmake/opentrack-qt.cmake index 5b851508..66618c59 100644 --- a/cmake/opentrack-qt.cmake +++ b/cmake/opentrack-qt.cmake @@ -26,7 +26,7 @@ if(MSVC) # cross tools, etc. which is a can of worms and if/else branches. get_filename_component(linker-dir "${CMAKE_LINKER}" DIRECTORY) find_file(editbin-executable-filepath "editbin.exe" "${linker-dir}" "${linker-dir}/.." "${linker-dir}/../..") - opentrack_escape_string("${editbin-executable-filepath}" editbin-executable) + otr_escape_string("${editbin-executable-filepath}" editbin-executable) else() set(editbin-executable "editbin") endif() diff --git a/cmake/opentrack-rift.cmake b/cmake/opentrack-rift.cmake index 63ee47e5..88adbb3e 100644 --- a/cmake/opentrack-rift.cmake +++ b/cmake/opentrack-rift.cmake @@ -1,40 +1,37 @@ -if(NOT opentrack-rift-included) - set(opentrack-rift-included TRUE) - function(opentrack_rift_boilerplate proj opt) - if(${opt}) - set(link-flags) - set(c-flags) - if(APPLE) - set(link-flags "-framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Quartz") - set(c-flags "-fno-strict-aliasing") - elseif(NOT MSVC) - set(c-flags "-fno-strict-aliasing") - endif() - opentrack_boilerplate(${proj} LINK ${link-flags} COMPILE ${c-flags}) - set(proj ${proj}) - target_include_directories(${proj} SYSTEM PUBLIC ${${opt}}/Include ${${opt}}/Src) - set(c-flags) - set(link-flags) - if(MSVC) - set(ext lib) - set(p) - else() - set(ext a) - set(p lib) - endif() - if(MSVC) - set(pfx "") - else() - set(pfx "lib") - endif() - target_link_libraries(${proj} ${${opt}}/${pfx}LibOVR.${ext}) - if(WIN32) - target_link_libraries(${proj} winmm setupapi ws2_32 imagehlp wbemuuid) - set(ext) - set(p) - elseif(NOT APPLE) - target_link_libraries(${proj} udev Xinerama) - endif() +function(otr_rift proj opt) + if(${opt}) + set(link-flags) + set(c-flags) + if(APPLE) + set(link-flags "-framework CoreFoundation -framework CoreGraphics -framework IOKit -framework Quartz") + set(c-flags "-fno-strict-aliasing") + elseif(NOT MSVC) + set(c-flags "-fno-strict-aliasing") endif() - endfunction() -endif() + otr_module(${proj} LINK ${link-flags} COMPILE ${c-flags}) + set(proj "opentrack-${proj}") + target_include_directories(${proj} SYSTEM PUBLIC ${${opt}}/Include ${${opt}}/Src) + set(c-flags) + set(link-flags) + if(MSVC) + set(ext lib) + set(p) + else() + set(ext a) + set(p lib) + endif() + if(MSVC) + set(pfx "") + else() + set(pfx "lib") + endif() + target_link_libraries(${proj} ${${opt}}/${pfx}LibOVR.${ext}) + if(WIN32) + target_link_libraries(${proj} winmm setupapi ws2_32 imagehlp wbemuuid) + set(ext) + set(p) + elseif(NOT APPLE) + target_link_libraries(${proj} udev Xinerama) + endif() + endif() +endfunction() diff --git a/cmake/opentrack-version.cmake b/cmake/opentrack-version.cmake index d5eba541..9cd597d3 100644 --- a/cmake/opentrack-version.cmake +++ b/cmake/opentrack-version.cmake @@ -42,4 +42,4 @@ add_library(opentrack-version STATIC ${CMAKE_BINARY_DIR}/version.c) if(NOT MSVC) set_property(TARGET opentrack-version APPEND_STRING PROPERTY COMPILE_FLAGS "-fno-lto") endif() -opentrack_compat(opentrack-version) +otr_compat(opentrack-version) |