summaryrefslogtreecommitdiffhomepage
path: root/cmake/opentrack-boilerplate.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/opentrack-boilerplate.cmake')
-rw-r--r--cmake/opentrack-boilerplate.cmake71
1 files changed, 45 insertions, 26 deletions
diff --git a/cmake/opentrack-boilerplate.cmake b/cmake/opentrack-boilerplate.cmake
index 84bd3a03..683f63a4 100644
--- a/cmake/opentrack-boilerplate.cmake
+++ b/cmake/opentrack-boilerplate.cmake
@@ -1,47 +1,57 @@
include_guard(GLOBAL)
-add_custom_target(moc COMMENT "Qt temporary files")
-
set(opentrack-perms-file WORLD_READ OWNER_WRITE OWNER_READ GROUP_READ)
set(opentrack-perms-dir WORLD_READ WORLD_EXECUTE OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE)
set(opentrack-perms-exec "${opentrack-perms-dir}")
set(new-hier-path "#pragma once
-#ifndef OPENTRACK_NO_QT_PATH
+#ifdef QT_CORE_LIB
# include <QCoreApplication>
# include <QString>
# include \"compat/base-path.hpp\"
#endif
+
+#if defined __APPLE__
+# define OPENTRACK_LIBRARY_EXTENSION \"dylib\"
+#elif defined _WIN32
+# define OPENTRACK_LIBRARY_EXTENSION \"dll\"
+#else
+# define OPENTRACK_LIBRARY_EXTENSION \"so\"
+#endif
+
+#define OPENTRACK_LIBRARY_PREFIX \"\"
#define OPENTRACK_LIBRARY_PATH \"${opentrack-hier-path}\"
#define OPENTRACK_DOC_PATH \"${opentrack-hier-doc}\"
#define OPENTRACK_CONTRIB_PATH \"${opentrack-hier-doc}contrib/\"
#define OPENTRACK_I18N_PATH \"${opentrack-i18n-path}\"
")
-include_directories("${CMAKE_BINARY_DIR}")
+function(otr_write_library_paths)
+ set(hier-path-filename "${CMAKE_BINARY_DIR}/opentrack-library-path.hxx")
+ 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()
+endfunction()
-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()
+otr_write_library_paths()
function(otr_glob_sources var)
set(basedir "${CMAKE_CURRENT_SOURCE_DIR}")
foreach(dir . ${ARGN})
set(dir "${basedir}/${dir}")
- file(GLOB ${var}-cxx ${dir}/*.cpp)
- file(GLOB ${var}-cc ${dir}/*.c)
- file(GLOB ${var}-hh ${dir}/*.h ${dir}/*.hpp)
- file(GLOB ${var}-res ${dir}/*.rc)
+ file(GLOB ${var}-cxx "${dir}/*.cpp")
+ file(GLOB ${var}-cc "${dir}/*.c")
+ file(GLOB ${var}-hh "${dir}/*.h" "${dir}/*.hpp" "${dir}/*.inc")
+ file(GLOB ${var}-res "${dir}/*.rc")
foreach(f ${var}-res)
set_source_files_properties(${f} PROPERTIES LANGUAGE RC)
endforeach()
- file(GLOB ${var}-ui ${dir}/*.ui)
- file(GLOB ${var}-rc ${dir}/*.qrc)
+ file(GLOB ${var}-ui "${dir}/*.ui")
+ file(GLOB ${var}-rc "${dir}/*.qrc")
set(${var}-all ${${var}-cc} ${${var}-cxx} ${${var}-hh} ${${var}-rc} ${${var}-res})
foreach(i ui rc res cc cxx hh all)
set(${var}-${i} "${${var}-${i}}" PARENT_SCOPE)
@@ -117,8 +127,6 @@ function(otr_install_pdb_current_project target)
endif()
endfunction()
-include(CMakeParseArguments)
-
function(otr_module n_)
message(STATUS "module ${n_}")
cmake_parse_arguments(arg
@@ -133,8 +141,6 @@ function(otr_module n_)
endif()
set(n "opentrack-${n_}")
- # XXX TODO update callers to use instead of long name -sh 20180527
- set(self "${n}" PARENT_SCOPE)
if(NOT arg_SUBDIRS)
otr_glob_sources(${n} .)
@@ -169,9 +175,11 @@ function(otr_module n_)
set_property(TARGET "${n}" PROPERTY PREFIX "")
endif()
- set_property(SOURCE ${${n}-moc} ${${n}-uih} PROPERTY GENERATED TRUE)
- add_custom_target(moc-${n} DEPENDS ${${n}-moc} ${${n}-uih} ${${n}-rc} COMMENT "")
- add_dependencies(moc "moc-${n}")
+ if(NOT arg_NO-QT)
+ otr_qt2("${n}")
+ endif()
+
+ set(self "${n}" PARENT_SCOPE)
if(NOT arg_RELINK)
set_property(TARGET ${n} PROPERTY LINK_DEPENDS_NO_SHARED TRUE)
@@ -201,6 +209,18 @@ function(otr_module n_)
set(arg_NO-INSTALL TRUE)
endif()
+ otr_compat(${n})
+
+ if(CMAKE_COMPILER_IS_CLANGXX AND (arg_EXECUTABLE OR NOT arg_BIN))
+ set(opts
+ weak-vtables
+ header-hygiene
+ )
+ foreach(k ${opts})
+ target_compile_options(${n} PRIVATE "-Wno-${k}")
+ endforeach()
+ endif()
+
if(NOT arg_NO-INSTALL)
if(arg_BIN AND WIN32)
install(TARGETS "${n}" RUNTIME DESTINATION . PERMISSIONS ${opentrack-perms-exec})
@@ -215,7 +235,6 @@ function(otr_module n_)
endif()
endif()
- otr_compat(${n})
if(NOT arg_NO-QT)
otr_i18n_for_target_directory(${n_})
endif()