-
Notifications
You must be signed in to change notification settings - Fork 14
/
CMakeLists.txt
154 lines (129 loc) · 5.71 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
cmake_minimum_required(VERSION 3.1)
#///////////////////////////////////////////////////////////////////#
# PROJECT #
#///////////////////////////////////////////////////////////////////#
set(OSL_VERSION_MAJOR 0)
set(OSL_VERSION_MINOR 9)
set(OSL_VERSION_PATCH 7)
set(PACKAGE_VERSION
${OSL_VERSION_MAJOR}.${OSL_VERSION_MINOR}.${OSL_VERSION_PATCH})
project(osl
LANGUAGES C)
# Default to Debug build
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
message(STATUS "No building type advertised, default to Release")
endif()
#///////////////////////////////////////////////////////////////////#
# DEPENDENCIES #
#///////////////////////////////////////////////////////////////////#
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
find_package(GMP)
if(GMP_FOUND)
add_library(gmp INTERFACE IMPORTED)
set_property(TARGET gmp
PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${GMP_INCLUDE_DIRS})
set_property(TARGET gmp
PROPERTY INTERFACE_LINK_LIBRARIES ${GMP_LIBRARIES})
else()
message(STATUS "GMP not found, using old style integers")
endif()
#///////////////////////////////////////////////////////////////////#
# COMPILATION OPTIONS #
#///////////////////////////////////////////////////////////////////#
option(BUILD_SHARED_LIBS
"Build as shared lib (default). Set to FALSE if you want static library"
TRUE)
include(cmake/compiler-flags.cmake)
set(CMAKE_C_FLAGS_RELEASE "-O3 -mtune=generic")
set(CMAKE_C_FLAGS_DEBUG
"${COMPILER_AVALIABLE_WARNINGS} ${COMPILER_ADDRESS_SANITIZER_FLAG} ${COMPILER_UNDEFINED_SANITIZER_FLAG} -Og -g")
set(CMAKE_C_FLAGS_OPTIMIZED
"${COMPILER_LTO_FLAG} ${COMPILER_MARCH_NATIVE} -O3")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g")
# Use full RPATH on build tree
set(CMAKE_SKIP_BUILD_RPATH FALSE)
# Do not build with install RPATH
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
# Set the RPATH when install
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# Only set RPATH if the installation directory is not a system directory
LIST(FIND
CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib"
isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
else()
set(CMAKE_INSTALL_RPATH "")
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/include/osl/scop.h.in
${CMAKE_CURRENT_BINARY_DIR}/include/osl/scop.h)
add_subdirectory(source)
#///////////////////////////////////////////////////////////////////#
# DOCUMENTATION #
#///////////////////////////////////////////////////////////////////#
add_subdirectory(doc)
#///////////////////////////////////////////////////////////////////#
# TEST #
#///////////////////////////////////////////////////////////////////#
enable_testing()
add_subdirectory(tests)
#///////////////////////////////////////////////////////////////////#
# INSTALL #
#///////////////////////////////////////////////////////////////////#
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"
DESTINATION include FILES_MATCHING PATTERN "*.h")
install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/include/"
DESTINATION include FILES_MATCHING PATTERN "*.h")
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P
${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
#///////////////////////////////////////////////////////////////////#
# USER INFOS #
#///////////////////////////////////////////////////////////////////#
message(STATUS "")
message(STATUS "************************* OSL *************************")
message(STATUS "")
message(STATUS "Configuration done.")
string(TOUPPER ${CMAKE_BUILD_TYPE} CURRENT_BUILD_TYPE)
if (CURRENT_BUILD_TYPE MATCHES RELEASE)
message(STATUS "Build type is Release")
message(STATUS "C compiler = ${CMAKE_C_COMPILER}")
message(STATUS "C flags = ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE}")
elseif(CURRENT_BUILD_TYPE MATCHES OPTIMIZED)
message(STATUS "C compiler = ${CMAKE_C_COMPILER}")
message(STATUS "C flags = ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_OPTIMIZED}")
elseif(CURRENT_BUILD_TYPE MATCHES RELWITHDEBINFO)
message(STATUS "C compiler = ${CMAKE_C_COMPILER}")
message(STATUS "C flags = ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELWITHDEBINFO}")
else(CURRENT_BUILD_TYPE MATCHES DEBUG)
message(STATUS "C compiler = ${CMAKE_C_COMPILER}")
message(STATUS "C flags = ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG}")
else(CURRENT_BUILD_TYPE MATCHES DEBUG)
message(STATUS "C compiler = ${CMAKE_C_COMPILER}")
message(STATUS "C flags = ${CMAKE_C_FLAGS}")
endif(CURRENT_BUILD_TYPE MATCHES RELEASE)
message(STATUS "")
message(STATUS "You can execute:")
message(STATUS " make # To compile osl library")
if (PYTHONINTERP_FOUND)
message(STATUS " make test # To execute tests")
endif()
message(STATUS " make install # To install library, include and CMake module")
message(STATUS " # If you need root access:")
message(STATUS " # sudo make install")
message(STATUS " # su -c \"make install\"")
if(DOXYGEN_FOUND)
message(STATUS " make doxygen # To generate the Doxygen")
endif()
if(texi2pdf_exe)
message(STATUS " make doc # To generate the documentation")
endif()
message(STATUS "")
message(STATUS "******************************************************")
message(STATUS "")