forked from vmware-archive/PDLTools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
143 lines (112 loc) · 5.08 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
# ======================================================================
# -- CMake setup
# ======================================================================
project(PDLTools)
cmake_minimum_required(VERSION 2.8.4 FATAL_ERROR)
include(ExternalProject)
# ======================================================================
# -- Local definitions (filenames, paths, etc.)
# ======================================================================
# The default PDL Tools root directory should be "/usr/local/pdltools" and not
# "/usr/local" (which is the CMake default)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/usr/local/pdltools" CACHE PATH
"Install path prefix, prepended onto install directories." FORCE
)
endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(PDLTOOLS_VERSION_YML ${CMAKE_CURRENT_SOURCE_DIR}/src/config/Version.yml)
set(PDLTOOLS_THIRD_PARTY ${CMAKE_BINARY_DIR}/third_party)
# Set the directory for tools needed during build time
set(PDLTOOLS_BUILD_TOOLS ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# Read and parse Version.yml file
message (" ------------------------------------------------------------")
message (" PDLTOOLS VERSION INFO (${PDLTOOLS_VERSION_YML})")
file(READ "${PDLTOOLS_VERSION_YML}" _PDLTOOLS_VERSION_CONTENTS)
string(REGEX REPLACE "^.*version:[ \t]*([^\n]*)\n.*" "\\1" PDLTOOLS_VERSION_STRING "${_PDLTOOLS_VERSION_CONTENTS}")
string(REGEX REPLACE "([0-9]+).*" "\\1" PDLTOOLS_VERSION_MAJOR "${PDLTOOLS_VERSION_STRING}")
string(REGEX REPLACE "[0-9]+\\.([0-9]+).*" "\\1" PDLTOOLS_VERSION_MINOR "${PDLTOOLS_VERSION_STRING}")
if("${PDLTOOLS_VERSION_STRING}" MATCHES "[0-9]+\\.[0-9]+\\.([0-9]+).*")
string(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" PDLTOOLS_VERSION_PATCH "${PDLTOOLS_VERSION_STRING}")
else()
set(PDLTOOLS_VERSION_PATCH 0)
endif()
message (" PDLTOOLS_VERSION_STRING .. : ${PDLTOOLS_VERSION_STRING}")
message (" PDLTOOLS_VERSION_MAJOR ... : ${PDLTOOLS_VERSION_MAJOR}")
message (" PDLTOOLS_VERSION_MINOR ... : ${PDLTOOLS_VERSION_MINOR}")
message (" PDLTOOLS_VERSION_PATCH ... : ${PDLTOOLS_VERSION_PATCH}")
message (" ------------------------------------------------------------")
# ------------------------------------------------------------------
# Find M4 binary (we need this for doxygen docs pre-processing)
# ------------------------------------------------------------------
if(SOLARIS)
# Solaris ships GNU m4 as gm4, so we want to use that
find_program(M4_BINARY gm4
PATHS /usr/sfw/bin
DOC "Path to the GNU m4 preprocessor."
)
else()
find_program(M4_BINARY m4
PATHS /usr/local/bin /usr/bin /bin /opt/local/bin
DOC "Path to the GNU m4 preprocessor."
)
endif()
if(NOT M4_BINARY)
message(FATAL_ERROR "Cannot find the m4 preprocessor.")
endif(NOT M4_BINARY)
# ===============================================================
# -- Install Read-me files and license directory
# ===============================================================
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/license"
DESTINATION .
COMPONENT core
PATTERN ".DS_Store" EXCLUDE
)
install(
FILES
"${CMAKE_CURRENT_SOURCE_DIR}/README.md"
DESTINATION doc
COMPONENT core
)
# ======================================================================
# -- Local includes
# ======================================================================
list(APPEND CMAKE_MODULE_PATH
"${PDLTOOLS_BUILD_TOOLS}")
include(Utils)
include(LinuxUtils)
include(OSXUtils)
if(CMAKE_COMPILER_IS_GNUCC)
# Let's store the gcc version in a variable
execute_process(
COMMAND ${CMAKE_C_COMPILER} -dumpversion
OUTPUT_VARIABLE GNUCC_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
# A useful summary of warning options can be found here:
# http://developer.apple.com/tools/xcode/compilercodewarnings.html
# Note: gcc does not implicitly set _POSIX_C_SOURCE or _XOPEN_SOURCE
# when using -std=c99.
# http://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html#tag_15_02_01_01
# We specify that we are POSIX.1-2001 compliant and XSI-conforming. We only
# need to specify _XOPEN_SOURCE as _POSIX_C_SOURCE will be set implicitly.
set(CMAKE_C_FLAGS "-std=c99 -pedantic -Wall -Wextra -D_XOPEN_SOURCE=600"
CACHE STRING
"Flags used by the compiler during all build types." FORCE)
endif()
# ======================================================================
# -- Add subdirectories
# ======================================================================
add_subdirectory(src)
add_subdirectory(deploy)
add_subdirectory(doc)
# ======================================================================
# -- Install path for specific pdltools version
# ======================================================================
set(CMAKE_PDLTOOLS_ROOT "${CMAKE_INSTALL_PREFIX}")
set(CMAKE_INSTALL_PREFIX "${CMAKE_PDLTOOLS_ROOT}/Versions/${PDLTOOLS_VERSION_STRING}")
# Create symlink doc
install(CODE "
EXECUTE_PROCESS(COMMAND ln -nsf
${CMAKE_PDLTOOLS_ROOT}/Current/doc
${CMAKE_PDLTOOLS_ROOT}/doc
)
")