blob: d84f9175c2b3375be4974cc10e9166c603b200ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
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;NO-LINKER-SCRIPT;LINKAGE"
"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 opentrack-compat)
endif()
target_link_libraries(${n} ${MY_QT_LIBS})
if(CMAKE_COMPILER_IS_GNUCXX AND NOT opentrack-foolib_NO-LINKER-SCRIPT)
set(l-flags)
if(NOT APPLE)
set(l-flags "-Wl,--as-needed -Wl,--version-script=\"${CMAKE_SOURCE_DIR}/opentrack-compat/${version-script}-version-script.txt\"")
endif()
set_target_properties(${n} PROPERTIES
LINK_FLAGS "${opentrack-foolib_LINK} ${opentrack-foolib_GNU-LINK} ${l-flags}"
COMPILE_FLAGS "${opentrack-foolib_COMPILE} ${opentrack-foolib_GNU-COMPILE} -fvisibility=hidden -fvisibility-inlines-hidden"
)
else()
set(c-props)
set(l-props)
if(opentrack-foolib_LINKAGE AND CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE)
set(c-props "${opentrack-foolib_COMPILE} ${opentrack-foolib_GNU-COMPILE} -fvisibility=hidden -fvisibility-inlines-hidden")
set(l-props "${opentrack-foolib_LINK} ${opentrack-foolib_GNU-LINK} -Wl,--as-needed")
else()
if(MSVC)
set(l-props "${msvc-subsystem} /DEBUG /OPT:ICF")
endif()
endif()
set_target_properties(${n} PROPERTIES
LINK_FLAGS "${l-props} ${opentrack-foolib_LINK}"
COMPILE_FLAGS "${c-props} ${opentrack-foolib_COMPILE}"
)
endif()
string(REGEX REPLACE "^opentrack-" "" n_ ${n})
string(REPLACE "-" "_" n_ ${n_})
target_compile_definitions(${n} PRIVATE "BUILD_${n_}")
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()
|