-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
113 lines (81 loc) · 3.04 KB
/
CMakeLists.txt
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#
# You rarely need to edit this file. To add or remove files in your
# project edit the "src" folders contents and run `mulle-sde reflect`.
#
# A convenient way to add a new source file is:
# mulle-sde add src/foo.m
#
cmake_minimum_required( VERSION 3.13)
project( mulle-pq VERSION 0.0.3 LANGUAGES C)
set( MULLE_PROJECT_TYPE "Executable")
### mulle-sde environment
# add cmake module paths to search path
list( INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/share")
list( INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/reflect")
list( INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include( Environment)
include( Files)
include( IDESupport OPTIONAL)
if( "${MULLE_PROJECT_TYPE}" STREQUAL "Executable")
### Executable
include( Dependencies)
include( Executable)
# use EXECUTABLE_COMPILE_TARGET for compiler options
target_compile_definitions( "${EXECUTABLE_COMPILE_TARGET}" PUBLIC)
target_compile_options( "${EXECUTABLE_COMPILE_TARGET}" PUBLIC)
# use EXECUTABLE_LINK_TARGET for linker options
if( LINK_PHASE)
target_link_options( "${EXECUTABLE_LINK_TARGET}" PUBLIC)
endif()
include( InstallExecutable)
# only for Executable
include( Motd OPTIONAL)
# If you only ever want to build this as an executable, you can throw
# everything else until endif() away
elseif( "${MULLE_PROJECT_TYPE}" STREQUAL "Framework")
### Framework
include( Dependencies)
include( Framework)
include( InstallFramework)
elseif( "${MULLE_PROJECT_TYPE}" STREQUAL "Library")
### Library
if( HEADER_PHASE)
install( FILES ${INSTALL_PUBLIC_HEADERS} DESTINATION "include/${PROJECT_NAME}")
install( FILES ${INSTALL_PRIVATE_HEADERS} DESTINATION "include/${PROJECT_NAME}")
install( FILES ${INSTALL_CMAKE_INCLUDES} DESTINATION "include/${PROJECT_NAME}/cmake")
# short cut out
if( NOT COMPILE_PHASE AND NOT LINK_PHASE)
return()
endif()
endif()
if( LINK_PHASE)
include( Dependencies OPTIONAL)
endif()
include( Library)
# use LIBRARY_COMPILE_TARGET for compiler options
target_compile_definitions( "${LIBRARY_COMPILE_TARGET}" PUBLIC)
target_compile_options( "${LIBRARY_COMPILE_TARGET}" PUBLIC)
# use LIBRARY_LINK_TARGET for linker options
if( LINK_PHASE)
target_link_options( "${LIBRARY_LINK_TARGET}" PUBLIC)
endif()
include( InstallLibrary)
else()
message( ERROR "Unknown project type \"${MULLE_PROJECT_TYPE}\"")
endif()
include( FinalOutput OPTIONAL)
# Advertisement:
#
# Turn an "Executable" into a "Library". This style of development is
# convenient for rapid startup coding where the finished result will be
# transformed into a library. You are also already writing the first
# test case! There is no code to throw away.
#
# * mulle-sde test init
# * mv src/main.m test/10-first/test.m
# * mulle-sde environment --scope project set PROJECT_TYPE library
# * mulle-sde reflect
# * mulle-sde test
#
# For this to work you need to separate the actual library code into source
# files outside of main.m.