summaryrefslogtreecommitdiffhomepage
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/opentrack-boilerplate.cmake18
-rw-r--r--cmake/opentrack-hier.cmake19
-rw-r--r--cmake/opentrack-install.cmake12
3 files changed, 43 insertions, 6 deletions
diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake
index 3838ca41..54643c42 100644
--- a/cmake/opentrack-boilerplate.cmake
+++ b/cmake/opentrack-boilerplate.cmake
@@ -1,3 +1,18 @@
+include(opentrack-hier)
+
+set(new-hier-path "#pragma once
+#define OPENTRACK_LIBRARY_PATH \"${opentrack-hier-path}\"
+")
+
+set(hier-path-filename "${CMAKE_BINARY_DIR}/opentrack-library-path.h")
+set(orig-hier-path "")
+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}")
+endif()
+
function(opentrack_set_globs n)
set(dir ${PROJECT_SOURCE_DIR})
file(GLOB ${n}-c ${dir}/*.cpp ${dir}/*.c ${dir}/*.h ${dir}/*.hpp)
@@ -42,6 +57,7 @@ function(opentrack_boilerplate__ n files_ no-library_ static_ no-compat_ compile
set(link-mode STATIC)
endif()
add_library(${n} ${link-mode} ${files_})
+ message(STATUS "module ${n}")
endif()
if(NOT no-library_)
opentrack_compat(${n})
@@ -75,7 +91,7 @@ function(opentrack_boilerplate__ n files_ no-library_ static_ no-compat_ compile
string(REPLACE "-" "_" n_ ${n_})
target_compile_definitions(${n} PRIVATE "BUILD_${n_}")
if((NOT static_) AND (NOT no-library_))
- install(TARGETS ${n} RUNTIME DESTINATION . LIBRARY DESTINATION .)
+ install(TARGETS ${n} ${opentrack-hier-str})
endif()
endfunction()
diff --git a/cmake/opentrack-hier.cmake b/cmake/opentrack-hier.cmake
new file mode 100644
index 00000000..8462531a
--- /dev/null
+++ b/cmake/opentrack-hier.cmake
@@ -0,0 +1,19 @@
+if(WIN32 OR APPLE OR CYGWIN)
+ set(opentrack-hier-pfx ".")
+ set(opentrack-hier-path "/./")
+ set(opentrack-hier-doc ".")
+ set(opentrack-hier-str RUNTIME DESTINATION . LIBRARY DESTINATION .)
+else()
+ set(opentrack-hier-pfx "libexec/opentrack")
+ set(opentrack-hier-path "/../libexec/opentrack/")
+ set(opentrack-hier-doc "share/doc/opentrack")
+ set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${opentrack-hier-pfx}")
+ set(opentrack-hier-str ARCHIVE DESTINATION lib/opentrack LIBRARY DESTINATION ${opentrack-hier-pfx} RUNTIME DESTINATION bin)
+endif()
+
+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 598572fa..a6ad1bad 100644
--- a/cmake/opentrack-install.cmake
+++ b/cmake/opentrack-install.cmake
@@ -1,17 +1,19 @@
+include(opentrack-hier)
+
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(FILES ${CMAKE_SOURCE_DIR}/README.md DESTINATION ${opentrack-hier-doc})
-install(DIRECTORY ${CMAKE_SOURCE_DIR}/3rdparty-notices DESTINATION .)
-install(DIRECTORY "${CMAKE_SOURCE_DIR}/settings" "${CMAKE_SOURCE_DIR}/contrib" DESTINATION .)
+install(DIRECTORY ${CMAKE_SOURCE_DIR}/3rdparty-notices DESTINATION ${opentrack-hier-doc})
+install(DIRECTORY "${CMAKE_SOURCE_DIR}/settings" "${CMAKE_SOURCE_DIR}/contrib" DESTINATION ${opentrack-hier-doc})
-install(FILES "${CMAKE_SOURCE_DIR}/bin/freetrackclient.dll" DESTINATION . ${opentrack-perms})
+install(FILES "${CMAKE_SOURCE_DIR}/bin/freetrackclient.dll" DESTINATION ${opentrack-hier-pfx} ${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})
+ DESTINATION ${opentrack-hier-pfx} ${opentrack-perms})