forked from go-nlopt/nlopt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
executable file
·77 lines (65 loc) · 2.25 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.1.3)
PROJECT(go-nlopt C CXX)
# Set build type
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
ENDIF(NOT CMAKE_BUILD_TYPE)
OPTION(FLYWAVE_ENABLE_SOLUTION_FOLDERS "Build with UBSAN" ON)
if(FLYWAVE_ENABLE_SOLUTION_FOLDERS)
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
SET_PROPERTY(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMakeTargets")
endif()
# Unix specific options
IF(UNIX OR APPLE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall")
ENDIF()
# CXX_STANDARD
SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17")
set(CMAKE_CXX_STANDARD_REQUIRED ON)
IF(UNIX)
IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
ENDIF()
ENDIF()
Set(FLYWAVE_BASE_INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib)
IF(APPLE)
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm")
SET(FLYWAVE_LIBRARY_OUTPUT_PATH "${FLYWAVE_BASE_INSTALL_DIR}/darwin_arm")
else()
SET(FLYWAVE_LIBRARY_OUTPUT_PATH "${FLYWAVE_BASE_INSTALL_DIR}/darwin")
endif()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++14")
ELSEIF(WIN32)
SET(FLYWAVE_LIBRARY_OUTPUT_PATH "${FLYWAVE_BASE_INSTALL_DIR}/windows")
ELSE()
SET(FLYWAVE_LIBRARY_OUTPUT_PATH "${FLYWAVE_BASE_INSTALL_DIR}/linux")
ENDIF()
MAKE_DIRECTORY(${FLYWAVE_LIBRARY_OUTPUT_PATH})
SET(FLYWAVE_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}")
SET(FLYWAVE_LIBRARY_DIRS "")
# NLOPT
IF(NOT NLOPT_INCLUDE)
ADD_SUBDIRECTORY("${CMAKE_CURRENT_SOURCE_DIR}/external/nlopt")
LIST(APPEND FLYWAVE_LIBRARY_DIRS "${CMAKE_CURRENT_BINARY_DIR}/external/nlopt/")
LIST(APPEND FLYWAVE_LIBRARY_DEPES "nlopt")
SET(NLOPT_INCLUDE YES)
ENDIF()
foreach(LIBDIR ${FLYWAVE_LIBRARY_DIRS})
INSTALL(
DIRECTORY ${LIBDIR}
DESTINATION ${FLYWAVE_LIBRARY_OUTPUT_PATH}
USE_SOURCE_PERMISSIONS FILE_PERMISSIONS
FILES_MATCHING PATTERN "*.a"
)
endforeach()
INSTALL(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/external/nlopt/src/api/"
DESTINATION ${FLYWAVE_BASE_INSTALL_DIR}
USE_SOURCE_PERMISSIONS FILE_PERMISSIONS
FILES_MATCHING PATTERN "*.h"
)