forked from mgalloy/mglib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
171 lines (135 loc) · 5.39 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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
project(mglib)
set(VERSION_MAJOR "1")
set(VERSION_MINOR "2")
set(VERSION_PATCH "0")
set(VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
# required version of CMake
cmake_minimum_required(VERSION 3.1.3)
cmake_policy(SET CMP0017 NEW)
if (POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif ()
set(CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/mgcmake/Modules
${CMAKE_ROOT}/Modules
${CMAKE_MODULE_PATH}
)
find_package(Git)
if (GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} log -1 --pretty=format:%h
OUTPUT_VARIABLE REVISION
)
else ()
set(REVISION "")
endif ()
include(${CMAKE_SOURCE_DIR}/mgcmake/GetDate.cmake)
LONG_TODAY(mglib_BUILD_DATE)
message(STATUS "Build date = ${mglib_BUILD_DATE}")
find_package(IDL REQUIRED)
find_package(IDLdoc)
find_package(mgunit)
find_package(idlwave)
# always need IDL's include files
include_directories(${IDL_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/dist_tools)
add_subdirectory(src)
add_subdirectory(scripts)
file(GLOB_RECURSE PRO_FILES "src/*.pro")
file(GLOB_RECURSE C_FILES "src/*.c")
file(GLOB_RECURSE DLM_FILES "src/*.dlm")
file(GLOB_RECURSE SAV_FILES "src/*.sav")
file(GLOB_RECURSE IDLDOC_FILES "src/*.idldoc")
if (WIN32 OR CYGWIN)
set(SEP_CHAR ";")
else ()
set(SEP_CHAR ":")
endif ()
if (IDLdoc_FOUND)
add_custom_target(doc
COMMAND ${IDL_EXECUTABLE} -IDL_STARTUP "\"\"" -IDL_PATH "${CMAKE_CURRENT_SOURCE_DIR}${SEP_CHAR}+${CMAKE_CURRENT_SOURCE_DIR}/src${SEP_CHAR}+${IDLdoc_DIR}${SEP_CHAR}\"<IDL_DEFAULT>\"" -e mg_doc_library -args ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT build developer API documentation
)
add_custom_target(userdoc
COMMAND ${IDL_EXECUTABLE} -IDL_STARTUP "\"\"" -IDL_PATH "${CMAKE_CURRENT_SOURCE_DIR}${SEP_CHAR}+${CMAKE_CURRENT_SOURCE_DIR}/src${SEP_CHAR}+${IDLdoc_DIR}${SEP_CHAR}\"<IDL_DEFAULT>\"" -e mg_userdoc_library -args ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT build user API documentation
)
find_package(LATEX)
set(TEX_BASENAME "index")
set(TEX_CLEAN_FILES "${TEX_BASENAME}.log;${TEX_BASENAME}.aux;${TEX_BASENAME}.idx;${TEX_BASENAME}.out;${TEX_BASENAME}.toc;${TEX_BASENAME}.blg")
if (PDFLATEX_COMPILER)
get_filename_component(LATEX_BINDIR "${PDFLATEX_COMPILER}" PATH)
set(XELATEX_COMPILER "${LATEX_BINDIR}/xelatex")
endif ()
if (EXISTS "${XELATEX_COMPILER}")
message(STATUS "Generating docs with ${XELATEX_COMPILER}")
set(TEX_CMD TEXINPUTS="${IDLdoc_DIR}/resources:" ${XELATEX_COMPILER} -interaction=batchmode ${CMAKE_CURRENT_BINARY_DIR}/api-bookdocs/index.tex)
set_directory_properties(PROPERTIES
ADDITIONAL_MAKE_CLEAN_FILES "${TEX_CLEAN_FILES}"
)
add_custom_target(bookdoc
COMMAND ${IDL_EXECUTABLE} -IDL_STARTUP "\"\"" -IDL_PATH "${CMAKE_CURRENT_SOURCE_DIR}${SEP_CHAR}+${CMAKE_CURRENT_SOURCE_DIR}/src${SEP_CHAR}+${IDLdoc_DIR}${SEP_CHAR}\"<IDL_DEFAULT>\"" -e mg_bookdoc_library -args ${CMAKE_CURRENT_SOURCE_DIR}\; cd ${CMAKE_CURRENT_BINARY_DIR}/api-bookdocs\; ${TEX_CMD}\; ${TEX_CMD}\; ${TEX_CMD}
COMMENT build user API documentation in LaTeX
)
endif ()
add_custom_target(upload_userdoc
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/upload_userdoc.sh ${CMAKE_CURRENT_BINARY_DIR}
COMMENT upload user documentation to idldev.com:~/docs.idldev.com/mglib
)
add_custom_target(dcdoc
COMMAND ${IDL_EXECUTABLE} -IDL_STARTUP "\"\"" -IDL_PATH "+${CMAKE_CURRENT_SOURCE_DIR}/src${SEP_CHAR}${CMAKE_CURRENT_SOURCE_DIR}${SEP_CHAR}+${IDLdoc_DIR}${SEP_CHAR}\"<IDL_DEFAULT>\"" -e mg_dcdoc_library -args ${CMAKE_CURRENT_SOURCE_DIR}
)
add_custom_target(dcdoc_dist
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/make_dc_dist.sh ${VERSION}
)
endif ()
if (mgunit_FOUND)
add_custom_target(unit
COMMAND ${IDL_EXECUTABLE} -IDL_STARTUP "\"\"" -IDL_PATH "${CMAKE_CURRENT_SOURCE_DIR}${SEP_CHAR}+${CMAKE_CURRENT_SOURCE_DIR}/src${SEP_CHAR}+${CMAKE_CURRENT_SOURCE_DIR}/unit${SEP_CHAR}+${mgunit_DIR}${SEP_CHAR}\"<IDL_DEFAULT>\"" -quiet -e mg_run_unittests
)
endif ()
set_directory_properties(PROPERTIES
ADDITIONAL_MAKE_CLEAN_FILES "api-docs;api-userdocs;api-dcdocs;api-bookdocs;mglib-test-results.html")
if (idlwave_FOUND)
configure_file("idlwave_catalog.cmake.in" "idlwave_catalog.cmake" @ONLY)
add_custom_target(idlwave_catalog
COMMAND ${idlwave_DIR}/idlwave_catalog -v mglib
WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}/lib)
endif ()
# setup installer
if (WIN32)
set(CPACK_GENERATOR ZIP)
else ()
set(CPACK_GENERATOR TGZ)
endif ()
string(TOLOWER "${CMAKE_SYSTEM_NAME}" MGLIB_SYSTEM_NAME)
set(MGLIB_PACKAGE_VERSION "${VERSION}.${REVISION}")
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${MGLIB_PACKAGE_VERSION}-${MGLIB_SYSTEM_NAME}")
include(CPack)
configure_file(idlpackage.json.in idlpackage.json @ONLY)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/idlpackage.json
DESTINATION .)
install(FILES
LICENSE
INSTALL.rst
README.rst
DESTINATION .)
install(DIRECTORY
examples
DESTINATION .)
if (IDLdoc_FOUND)
install(DIRECTORY ${CMAKE_BINARY_DIR}/api-docs DESTINATION . OPTIONAL)
install(DIRECTORY ${CMAKE_BINARY_DIR}/api-userdocs DESTINATION . OPTIONAL)
endif ()
if (mgunit_FOUND)
install(DIRECTORY unit DESTINATION .)
endif ()
add_custom_target(dist
COMMAND ${CMAKE_MAKE_PROGRAM} package
COMMENT "custom target to create distribution")
if (IDLdoc_FOUND)
add_dependencies(dist doc userdoc)
endif ()
message(STATUS "mglib ${VERSION}")
message(STATUS "Installation location = ${CMAKE_INSTALL_PREFIX}")