summaryrefslogtreecommitdiffhomepage
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/opentrack-install.cmake27
-rw-r--r--cmake/opentrack-macros.cmake79
-rw-r--r--cmake/opentrack-platform.cmake60
-rw-r--r--cmake/opentrack-policy.cmake10
-rw-r--r--cmake/opentrack-qt.cmake5
-rw-r--r--cmake/opentrack-rift.cmake37
-rw-r--r--cmake/opentrack-tarball.cmake23
-rw-r--r--cmake/opentrack-version.cmake33
8 files changed, 274 insertions, 0 deletions
diff --git a/cmake/opentrack-install.cmake b/cmake/opentrack-install.cmake
new file mode 100644
index 00000000..8e3d0420
--- /dev/null
+++ b/cmake/opentrack-install.cmake
@@ -0,0 +1,27 @@
+set(opentrack-perms PERMISSIONS WORLD_READ WORLD_EXECUTE OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE)
+
+if(WIN32)
+ install(FILES "${CMAKE_SOURCE_DIR}/bin/cleye.config" DESTINATION .)
+endif()
+
+install(FILES ${CMAKE_SOURCE_DIR}/README.md DESTINATION .)
+
+install(DIRECTORY ${CMAKE_SOURCE_DIR}/3rdparty-notices DESTINATION .)
+install(DIRECTORY "${CMAKE_SOURCE_DIR}/settings" "${CMAKE_SOURCE_DIR}/contrib" DESTINATION .)
+
+install(FILES "${CMAKE_SOURCE_DIR}/bin/freetrackclient.dll" DESTINATION . ${opentrack-perms})
+install(FILES
+ "${CMAKE_SOURCE_DIR}/bin/NPClient.dll"
+ "${CMAKE_SOURCE_DIR}/bin/NPClient64.dll"
+ "${CMAKE_SOURCE_DIR}/bin/TrackIR.exe"
+ DESTINATION . ${opentrack-perms})
+
+if(APPLE)
+ install(CODE "
+ execute_process(COMMAND /bin/sh \"${CMAKE_SOURCE_DIR}/macosx/make-app-bundle.sh\"
+ \"${CMAKE_SOURCE_DIR}/macosx\"
+ \"${CMAKE_INSTALL_PREFIX}\"
+ \"${CMAKE_BINARY_DIR}\"
+ \"${OPENTRACK_COMMIT}\")
+ ")
+endif()
diff --git a/cmake/opentrack-macros.cmake b/cmake/opentrack-macros.cmake
new file mode 100644
index 00000000..a9fa5bc7
--- /dev/null
+++ b/cmake/opentrack-macros.cmake
@@ -0,0 +1,79 @@
+macro(opentrack_module n dir)
+ file(GLOB ${n}-c ${dir}/*.cpp ${dir}/*.c ${dir}/*.h ${dir}/*.hpp)
+ file(GLOB ${n}-res ${dir}/*.rc)
+ foreach(f ${n}-res)
+ set_source_files_properties(${f} PROPERTIES LANGUAGE RC)
+ endforeach()
+ file(GLOB ${n}-ui ${dir}/*.ui)
+ file(GLOB ${n}-rc ${dir}/*.qrc)
+endmacro()
+
+macro(opentrack_boilerplate opentrack-project-name)
+ set(extra_macro_args ${ARGN})
+ set(spliced ${extra_macro_args})
+ project(${opentrack-project-name})
+ opentrack_library(${opentrack-project-name} ${PROJECT_SOURCE_DIR} ${spliced})
+ set(spliced)
+endmacro()
+
+macro(opentrack_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})
+ set(${n}-all ${${n}-c} ${${n}-rc} ${${n}-rcc} ${${n}-uih} ${${n}-moc} ${${n}-res})
+endmacro()
+
+set(msvc-subsystem "/VERSION:5.1 /SUBSYSTEM:WINDOWS,5.01")
+function(opentrack_compat target)
+ if(MSVC)
+ set_target_properties(${target} PROPERTIES LINK_FLAGS "${msvc-subsystem} /DEBUG /OPT:ICF")
+ endif()
+endfunction()
+
+macro(opentrack_library n dir)
+ cmake_parse_arguments(opentrack-foolib
+ "NO-LIBRARY;STATIC;NO-COMPAT"
+ "LINK;COMPILE;GNU-LINK;GNU-COMPILE"
+ ""
+ ${ARGN}
+ )
+ if(NOT " ${opentrack-foolib_UNPARSED_ARGUMENTS}" STREQUAL " ")
+ message(FATAL_ERROR "opentrack_library bad formals ${opentrack-foolib_UNPARSED_ARGUMENTS}")
+ endif()
+ opentrack_module(${n} ${dir})
+ opentrack_qt(${n})
+ set(link-mode SHARED)
+ if(NOT opentrack-foolib_NO-LIBRARY)
+ if (opentrack-foolib_STATIC)
+ set(link-mode STATIC)
+ endif()
+ add_library(${n} ${link-mode} ${${n}-all})
+ set(link-mode)
+ if(NOT opentrack-foolib_NO-COMPAT)
+ target_link_libraries(${n} opentrack-api ${MY_QT_LIBS} opentrack-compat)
+ endif()
+ if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
+ SET_TARGET_PROPERTIES(${n} PROPERTIES
+ LINK_FLAGS "${opentrack-foolib_LINK} ${opentrack-foolib_GNU-LINK} -Wl,--as-needed -Wl,--version-script=\"${CMAKE_SOURCE_DIR}/opentrack-compat/${version-script}-version-script.txt\""
+ COMPILE_FLAGS "${opentrack-foolib_COMPILE} ${opentrack-foolib_GNU-COMPILE} -fvisibility=hidden -fvisibility-inlines-hidden"
+ )
+ else()
+ set(link-flags)
+ if(MSVC)
+ set(link-flags "${msvc-subsystem} /DEBUG /OPT:ICF")
+ endif()
+ set_target_properties(${n} PROPERTIES LINK_FLAGS "${link-flags} ${opentrack-foolib_LINK}" COMPILE_FLAGS "${opentrack-foolib_COMPILE}")
+ set(link-flags)
+ endif()
+ if(NOT opentrack-foolib_STATIC)
+ install(TARGETS ${n} RUNTIME DESTINATION . LIBRARY DESTINATION .)
+ endif()
+ opentrack_compat(${n})
+ endif()
+endmacro()
+
+function(link_with_dinput8 n)
+ if(WIN32)
+ target_link_libraries(${n} dinput8 dxguid strmiids)
+ endif()
+endfunction()
diff --git a/cmake/opentrack-platform.cmake b/cmake/opentrack-platform.cmake
new file mode 100644
index 00000000..aac3a2b8
--- /dev/null
+++ b/cmake/opentrack-platform.cmake
@@ -0,0 +1,60 @@
+IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ set(LINUX TRUE)
+endif()
+
+if(MSVC)
+ add_definitions(-DNOMINMAX -D_CRT_SECURE_NO_WARNINGS)
+endif()
+
+if(WIN32)
+ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC)
+ set(CMAKE_RC_COMPILER_INIT i686-w64-mingw32-windres)
+ SET(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> --use-temp-file -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
+ endif()
+ ENABLE_LANGUAGE(RC)
+endif(WIN32)
+
+set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+set(CMAKE_SKIP_INSTALL_RPATH FALSE)
+set(CMAKE_SKIP_RPATH FALSE)
+set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX})
+set(CMAKE_INCLUDE_CURRENT_DIR ON)
+set(CMAKE_AUTOMOC OFF)
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+
+include_directories(${CMAKE_SOURCE_DIR})
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
+# note, hatire supports both ftnoir and opentrack
+# don't remove without being sure as hell -sh 20140922
+add_definitions(-DOPENTRACK_API)
+
+if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
+ set(CMAKE_COMPILER_IS_GNUCC TRUE)
+ set(CMAKE_COMPILER_IS_GNUCXX TRUE)
+endif()
+
+if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
+ if(MINGW)
+ set(version-script mingw)
+ else()
+ set(version-script posix)
+ endif()
+endif()
+
+if(APPLE)
+ set(CMAKE_MACOSX_RPATH OFF)
+ set(apple-frameworks "-stdlib=libc++ -framework Cocoa -framework CoreFoundation -lobjc -lz -framework Carbon")
+ set(CMAKE_SHARED_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_SHARED_LINKER_FLAGS}")
+ #set(CMAKE_STATIC_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_STATIC_LINKER_FLAGS}")
+ set(CMAKE_EXE_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_EXE_LINKER_FLAGS}")
+ set(CMAKE_MODULE_LINKER_FLAGS " ${apple-frameworks} ${CMAKE_MODULE_LINKER_FLAGS}")
+ set(CMAKE_CXX_FLAGS " -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
+endif()
+
+if(CMAKE_COMPILER_IS_GNUCXX OR APPLE)
+ set(CMAKE_CXX_FLAGS " -std=c++11 ${CMAKE_CXX_FLAGS} ")
+endif()
+
+set_property(GLOBAL PROPERTY USE_FOLDERS OFF)
diff --git a/cmake/opentrack-policy.cmake b/cmake/opentrack-policy.cmake
new file mode 100644
index 00000000..48aba3cc
--- /dev/null
+++ b/cmake/opentrack-policy.cmake
@@ -0,0 +1,10 @@
+cmake_policy(SET CMP0020 NEW)
+if(POLICY CMP0058)
+ cmake_policy(SET CMP0058 OLD)
+endif()
+if(POLICY CMP0028)
+ cmake_policy(SET CMP0028 OLD)
+endif()
+if(POLICY CMP0042)
+ cmake_policy(SET CMP0042 NEW)
+endif()
diff --git a/cmake/opentrack-qt.cmake b/cmake/opentrack-qt.cmake
new file mode 100644
index 00000000..12966827
--- /dev/null
+++ b/cmake/opentrack-qt.cmake
@@ -0,0 +1,5 @@
+find_package(Qt5 REQUIRED COMPONENTS Core Xml Network Widgets Gui QUIET)
+find_package(Qt5 COMPONENTS SerialPort QUIET)
+include_directories(SYSTEM ${Qt5Core_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS})
+add_definitions(${Qt5Core_DEFINITIONS} ${Qt5Xml_DEFINITIONS} ${Qt5Gui_DEFINITIONS} ${Qt5Widgets_DEFINITIONS} ${Qt5Network_DEFINITIONS})
+set(MY_QT_LIBS ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES})
diff --git a/cmake/opentrack-rift.cmake b/cmake/opentrack-rift.cmake
new file mode 100644
index 00000000..86396637
--- /dev/null
+++ b/cmake/opentrack-rift.cmake
@@ -0,0 +1,37 @@
+macro(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")
+ else()
+ if(NOT MSVC)
+ set(c-flags "-fno-strict-aliasing")
+ endif()
+ endif()
+ opentrack_boilerplate("${proj}" LINK ${link-flags} COMPILE ${c-flags})
+ set(proj ${opentrack-project-name})
+ target_include_directories(${proj} SYSTEM PUBLIC ${${opt}}/Include ${${opt}}/Src)
+ set(c-flags)
+ set(link-flags)
+ if(WIN32)
+ if(MSVC)
+ set(ext lib)
+ set(p)
+ else()
+ set(ext a)
+ set(p lib)
+ endif()
+ target_link_libraries(${proj} ${${opt}}/${p}LibOVR.${ext} winmm setupapi ws2_32 imagehlp wbemuuid)
+ set(ext)
+ set(p)
+ else()
+ if(NOT APPLE)
+ target_link_libraries(${proj} ${${opt}}/libLibOVR.a udev Xinerama)
+ else()
+ target_link_libraries(${proj} ${${opt}}/libLibOVR.a)
+ endif()
+ endif()
+ endif()
+endmacro()
diff --git a/cmake/opentrack-tarball.cmake b/cmake/opentrack-tarball.cmake
new file mode 100644
index 00000000..6b40081b
--- /dev/null
+++ b/cmake/opentrack-tarball.cmake
@@ -0,0 +1,23 @@
+string(TIMESTAMP filename-date "%Y%m%d")
+set(filename-ostype ${CMAKE_SYSTEM_NAME})
+get_git_head_revision(filename-branch_0 filename-hash_0)
+if(filename-hash_0)
+ string(SUBSTRING "${filename-hash_0}" 0 7 filename-hash)
+endif()
+string(REPLACE "refs/heads/" "" filename-branch_1 "${filename-branch_0}")
+string(REPLACE "/" "-" filename-branch "${filename-branch_1}")
+set(filename_0 "${OPENTRACK_COMMIT}")
+set(filename_1)
+if (NOT OPENTRACK_TAG_EXACT STREQUAL OPENTRACK_COMMIT)
+ string(TIMESTAMP filename_1 "-%Y%m%d%H%M%S")
+endif()
+set(filename "${CMAKE_BINARY_DIR}/${filename_0}${filename_1}.zip")
+
+add_custom_target(tarball-real)
+add_custom_target(tarball-real2)
+add_custom_command(TARGET tarball-real COMMAND cmake -P ${CMAKE_SOURCE_DIR}/cmake/tarball.cmake)
+
+add_custom_command(TARGET tarball-real2 COMMAND /usr/bin/env sh
+ "${CMAKE_SOURCE_DIR}/make-tar.sh" "${CMAKE_INSTALL_PREFIX}"
+ "${filename}" "${CMAKE_BINARY_DIR}")
+add_custom_target(tarball DEPENDS tarball-real)
diff --git a/cmake/opentrack-version.cmake b/cmake/opentrack-version.cmake
new file mode 100644
index 00000000..64072e1c
--- /dev/null
+++ b/cmake/opentrack-version.cmake
@@ -0,0 +1,33 @@
+include(GetGitRevisionDescription)
+
+find_package(Git QUIET)
+if(GIT_FOUND)
+ git_describe(OPENTRACK_COMMIT --tags --always --dirty)
+ git_describe(OPENTRACK_TAG_EXACT --tag --exact)
+endif()
+
+file(WRITE ${CMAKE_BINARY_DIR}/opentrack-version.h "#define OPENTRACK_VERSION \"${OPENTRACK_COMMIT}\"")
+
+add_library(opentrack-version STATIC ${CMAKE_BINARY_DIR}/version.cc)
+opentrack_compat(opentrack-version)
+
+set(version-string "
+#include \"opentrack-compat/export.hpp\"
+
+#ifdef __cplusplus
+extern \"C\"
+#endif
+OPENTRACK_EXPORT
+const char* opentrack_version;
+
+const char* opentrack_version = \"${OPENTRACK_COMMIT}\";
+")
+
+set(crapola-ver)
+if(EXISTS ${CMAKE_BINARY_DIR}/version.cc)
+ file(READ ${CMAKE_BINARY_DIR}/version.cc crapola-ver)
+endif()
+
+if(NOT (crapola-ver STREQUAL version-string))
+ file(WRITE ${CMAKE_BINARY_DIR}/version.cc "${version-string}")
+endif()