forked from BlueQuartzSoftware/CMP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmpProject.cmake
executable file
·129 lines (105 loc) · 4.85 KB
/
cmpProject.cmake
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
if(NOT DEFINED CMP_SOURCE_DIR)
get_filename_component(CMP_SOURCE_DIR ${CMAKE_CURRENT_LIST_FILE} PATH CACHE)
endif()
set(CMP_CONFIGURED_FILES_SOURCE_DIR ${CMP_SOURCE_DIR}/ConfiguredFiles CACHE INTERNAL "")
set(CMP_CORE_TESTS_SOURCE_DIR ${CMP_SOURCE_DIR}/CoreTests CACHE INTERNAL "")
set(CMP_INSTALLATION_SUPPORT_SOURCE_DIR ${CMP_SOURCE_DIR}/InstallationSupport CACHE INTERNAL "")
set(CMP_MODULES_SOURCE_DIR ${CMP_SOURCE_DIR}/Modules CACHE INTERNAL "")
set(CMP_OSX_TOOLS_SOURCE_DIR ${CMP_SOURCE_DIR}/OSX_Tools CACHE INTERNAL "")
set(CMP_LINUX_TOOLS_SOURCE_DIR ${CMP_SOURCE_DIR}/Linux_Tools CACHE INTERNAL "")
# --------------------------------------------------------------------
# Over ride CMake's built in module directory by prepending cmp's module
# directory first
set(CMAKE_MODULE_PATH ${CMP_MODULES_SOURCE_DIR} ${CMAKE_MODULE_PATH})
include(${CMP_SOURCE_DIR}/cmpCMakeMacros.cmake)
include(${CMP_CORE_TESTS_SOURCE_DIR}/cmpConfigureChecks.cmake)
if(NOT DEFINED CMP_PROJECT_NAMESPACE)
set(CMP_PROJECT_NAMESPACE "CMP")
endif()
if(NOT DEFINED CMP_HEADER_DIR)
set(CMP_HEADER_DIR ${PROJECT_BINARY_DIR}/cmp)
endif()
if(NOT DEFINED CMP_CONFIGURATION_FILE_NAME)
set(CMP_CONFIGURATION_FILE_NAME "cmpConfiguration.h")
endif()
if(NOT DEFINED CMP_TYPES_FILE_NAME)
set(CMP_TYPES_FILE_NAME "cmpTypes.h")
endif()
if(NOT DEFINED CMP_VERSION_HEADER_FILE_NAME)
set(CMP_VERSION_HEADER_FILE_NAME "cmpVersion.h")
endif()
if(NOT DEFINED CMP_VERSION_SOURCE_FILE_NAME)
set(CMP_VERSION_HEADER_FILE_NAME "cmpVersion.cpp")
endif()
if(NOT DEFINED CMP_VERSION_MACRO_FILE_NAME)
set(CMP_VERSION_MACRO_FILE_NAME "cmpVersionMacro.h")
endif()
if(NOT DEFINED CMP_TOP_HEADER_FILE)
set(CMP_TOP_HEADER_FILE "")
endif()
if(NOT DEFINED CMP_PROJECT_NAME)
set(CMP_PROJECT_NAME "CMP")
endif()
if(NOT DEFINED CMP_PLUGIN_LIST_FILE)
set(CMP_PLUGIN_LIST_FILE ${PROJECT_BINARY_DIR}/plugins.txt)
endif()
if(NOT DEFINED CMP_PLUGIN_SEARCHDIR_FILE)
set(CMP_PLUGIN_SEARCHDIR_FILE ${PROJECT_BINARY_DIR}/libsearchdirs.txt)
endif()
if(NOT DEFINED CMP_STRING_CLASS)
set(CMP_STRING_CLASS "QString")
endif()
if(NOT DEFINED CMP_STRING_INCLUDE)
set(CMP_STRING_INCLUDE "<QtCore/QString>")
endif()
get_filename_component(CMP_CONFIGURATION_HEADER_GUARD ${CMP_CONFIGURATION_FILE_NAME} NAME_WE)
get_filename_component(CMP_TYPES_HEADER_GUARD ${CMP_TYPES_FILE_NAME} NAME_WE)
get_filename_component(CMP_VERSION_HEADER_GUARD ${CMP_VERSION_HEADER_FILE_NAME} NAME_WE)
# --------------------------------------------------------------------
# Generate our header files
# --------------------------------------------------------------------
cmpConfigureFileWithMD5Check(CONFIGURED_TEMPLATE_PATH ${CMP_CONFIGURED_FILES_SOURCE_DIR}/cmpConfiguration.h.in
GENERATED_FILE_PATH ${CMP_HEADER_DIR}/${CMP_CONFIGURATION_FILE_NAME}
)
cmpConfigureFileWithMD5Check(CONFIGURED_TEMPLATE_PATH ${CMP_CONFIGURED_FILES_SOURCE_DIR}/cmpPrimitiveTypes.h.in
GENERATED_FILE_PATH ${CMP_HEADER_DIR}/${CMP_TYPES_FILE_NAME}
)
# --------------------------------------------------------------------
# Generate a Header file with Compile Version variables
# --------------------------------------------------------------------
if(${CMP_GENERATE_VERSION_STRING})
# Find Git executable
find_package(Git)
set(PROJECT_EXPORT_MACRO ${CMP_PROJECT_NAMESPACE}_EXPORT)
if("${CMP_PROJECT_NAMESPACE}" STREQUAL "")
set(PROJECT_EXPORT_MACRO "")
endif()
cmpRevisionString(GENERATED_HEADER_FILE_PATH "${CMP_VERSION_HEADER_FILE_NAME}"
GENERATED_SOURCE_FILE_PATH "${CMP_VERSION_SOURCE_FILE_NAME}"
GENERATED_MACRO_HEADER_PATH "${CMP_VERSION_MACRO_FILE_NAME}"
NAMESPACE "${CMP_PROJECT_NAMESPACE}"
PROJECT_NAME "${PROJECT_NAME}"
EXPORT_MACRO "${PROJECT_EXPORT_MACRO}"
STRING_CLASS "${CMP_STRING_CLASS}"
STRING_INCLUDE "${CMP_STRING_INCLUDE}"
)
endif()
set(CMP_GENERATED_HEADERS
"${CMP_HEADER_DIR}/${CMP_CONFIGURATION_FILE_NAME}"
"${CMP_HEADER_DIR}/${CMP_TYPES_FILE_NAME}"
"${CMP_HEADER_DIR}/${CMP_VERSION_HEADER_FILE_NAME}"
)
set(CMP_GENERATED_SOURCES
"${CMP_HEADER_DIR}/${CMP_VERSION_SOURCE_FILE_NAME}"
)
cmp_IDE_GENERATED_PROPERTIES("Generated" ${CMP_GENERATED_HEADERS} ${CMP_GENERATED_SOURCES})
# --------------------------------------------------------------------
# Enable the use of plugins that will get generated as part of the project
# We are going to write the paths to the plugins into a file and then that
# file will be used as input to set an actual cmake variable and then
# passed to the bundle utilities cmake macro.
if(CMP_ENABLE_PLUGINS)
file(WRITE ${CMP_PLUGIN_LIST_FILE} "")
file(WRITE ${CMP_PLUGIN_SEARCHDIR_FILE} "${PROJECT_BINARY_DIR}/Bin/Plugins;")
file(APPEND ${CMP_PLUGIN_SEARCHDIR_FILE} "${PROJECT_BINARY_DIR}/Bin;")
endif()