-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
190 lines (161 loc) · 5.21 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
############################################################################
# #
# file: CMakeLists.txt #
# Copyright (C) 2016 #
# Enrico Bertolazzi #
# Dipartimento di Ingegneria Industriale #
# Universita` degli Studi di Trento #
# email: [email protected] #
# #
############################################################################
cmake_minimum_required(VERSION 3.14)
project( quarticRootsFlocke )
if (IS_DIRECTORY "${PROJECT_SOURCE_DIR}/cmake_utils")
set( HOME "${PROJECT_SOURCE_DIR}/cmake_utils/" )
else()
if (IS_DIRECTORY "${PROJECT_SOURCE_DIR}/../cmake_utils")
set( HOME "${PROJECT_SOURCE_DIR}/../cmake_utils/" )
else()
set( HOME "${PROJECT_SOURCE_DIR}/../../cmake_utils/" )
endif()
endif()
include( "${HOME}/CMakeLists-common.txt" )
project(
${PROJECT_NAME}
VERSION ${UTILS_PROJECT_VERSION}
HOMEPAGE_URL "https://ebertolazzi.github.io/quarticRootsFlocke/"
)
include( "${HOME}/CMakeLists-cflags.txt" )
include( "${HOME}/CMakeLists-utilities.txt" )
# Evaluating the suffix to append to target built by this CMake file
utils_artifacts_suffix(ARTIFACTS_STATIC_SUFFIX TRUE)
if( UTILS_BUILD_SHARED )
utils_artifacts_suffix(ARTIFACTS_DYNAMIC_SUFFIX FALSE)
endif()
message( STATUS "Compiler used: ${CMAKE_CXX_COMPILER_ID}" )
message( STATUS "BASE SUFFIXES = ${ARTIFACTS_STATIC_SUFFIX} ${ARTIFACTS_DYNAMIC_SUFFIX}" )
if( EXISTS "${CMAKE_CURRENT_LIST_DIR}/../CMakeLists-customize.txt" )
include(${CMAKE_CURRENT_LIST_DIR}/../CMakeLists-customize.txt)
endif()
if(APPLE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLUA_USE_MACOSX")
elseif(LINUX OR UNIX)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLUA_USE_LINUX")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
endif()
set(LUALIB Lua)
# ___
# / __| ___ _ _ _ _ __ ___ ___
# \__ \/ _ \ || | '_/ _/ -_|_-<
# |___/\___/\_,_|_| \__\___/__/
#
set( SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src" )
set( SOURCES )
file(
GLOB S
${SOURCE_DIR}/*.cc
)
foreach(F ${S})
# build relative path respect to source directory
file( RELATIVE_PATH RF ${SOURCE_DIR} "${F}" )
list( APPEND SOURCES ${RF} )
endforeach(F ${S})
# _ _ _
# | || |___ __ _ __| |___ _ _ ___
# | __ / -_) _` / _` / -_) '_(_-<
# |_||_\___\__,_\__,_\___|_| /__/
#
set( PUBLIC_HEADERS )
file(
GLOB_RECURSE S
${SOURCE_DIR}/*.h*
${SOURCE_DIR}/Eigen/*
)
foreach (F ${S})
# build relative path respect to source directory
file( RELATIVE_PATH RF "${SOURCE_DIR}" "${F}" )
list( APPEND PUBLIC_HEADERS ${RF} )
endforeach(F ${S})
list(FILTER PUBLIC_HEADERS EXCLUDE REGEX "\.DS")
# extra include directory for compilation
include_directories( ./src ./src/Utils )
# _____ _
# |_ _|_ _ _ _ __ _ ___| |_ ___
# | |/ _` | '_/ _` / -_) _(_-<
# |_|\__,_|_| \__, \___|\__/__/
# |___/
#
# define target
utils_setup_target(
${PROJECT_NAME}
TRUE # build static
"${SOURCE_DIR}"
"${SOURCES}"
"${SOURCE_DIR}"
"${PUBLIC_HEADERS}"
)
if ( UTILS_BUILD_SHARED )
utils_setup_target(
${PROJECT_NAME}
FALSE # build dynamic
"${SOURCE_DIR}"
"${SOURCES}"
"${SOURCE_DIR}"
"${PUBLIC_HEADERS}"
)
endif()
# _____ _
# |_ _|__ __| |_ ___
# | |/ -_|_-< _(_-<
# |_|\___/__/\__/__/
#
if ( UTILS_ENABLE_TESTS )
enable_testing()
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_SOURCE_DIR}/bin )
set( LIBS ${UTILS_NAMESPACE}_${PROJECT_NAME}_Static ${CMAKE_DL_LIBS} )
if( UNIX AND NOT APPLE )
set( THREADS_PREFER_PTHREAD_FLAG ON )
find_package( Threads REQUIRED )
set( LIBS ${LIBS} Threads::Threads )
endif()
set( EXELISTCPP )
file(
GLOB S
${CMAKE_CURRENT_SOURCE_DIR}/src_tests/*.cc
)
foreach(F ${S})
file( RELATIVE_PATH RF "${CMAKE_CURRENT_SOURCE_DIR}/src_tests/" "${F}" )
get_filename_component( RFF ${RF} NAME_WLE )
list( APPEND EXELISTCPP ${RFF} )
endforeach(F ${S})
add_custom_target( "${PROJECT_NAME}_all_tests" ALL )
foreach( S ${EXELISTCPP} )
add_executable( ${S} ${CMAKE_CURRENT_SOURCE_DIR}/src_tests/${S}.cc )
target_link_libraries( ${S} ${LIBS} )
set_target_properties( ${S} PROPERTIES SUFFIX ".exe" )
add_test( NAME "${S}" COMMAND ./bin/${S}.exe WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
add_dependencies( "${PROJECT_NAME}_all_tests" ${S} )
endforeach()
endif()
# ___ _ _ _
# |_ _|_ _ __| |_ __ _| | |
# | || ' \(_-< _/ _` | | |
# |___|_||_/__/\__\__,_|_|_|
#
install(
TARGETS ${TARGETS_TO_BE_INSTALLED}
# EXPORT (da definire)
LIBRARY DESTINATION ${INSTALL_PREFIX}/dll
ARCHIVE DESTINATION ${INSTALL_PREFIX}/lib
RUNTIME DESTINATION ${INSTALL_PREFIX}/bin
PUBLIC_HEADER DESTINATION ${PROJECT_PUBLIC_HEADER_DESTINATION}
)
# ___ _
# | _ \__ _ __| |____ _ __ _ ___
# | _/ _` / _| / / _` / _` / -_)
# |_| \__,_\__|_\_\__,_\__, \___|
# |___/
#
include( "${HOME}/CMakeLists-cpack.txt" )
utils_final_messages()