-
Notifications
You must be signed in to change notification settings - Fork 26
/
CMakeLists.txt
42 lines (31 loc) · 1.28 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
cmake_minimum_required(VERSION 2.8)
project(c-cmaes)
# Options
option(COMPILE_EXAMPLES "Compile the examples" ON)
# Build paths
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
# Source directory
set(CCMAES_SRC_DIR ${PROJECT_SOURCE_DIR}/src)
# Compilation flags
set(CMAKE_C_FLAGS "-ansi -pedantic -Wall -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wshadow")
# Header directory
include_directories(CCMAES_SRC_DIR)
# Source files
set(CCMAES_SRC "${CCMAES_SRC_DIR}/cmaes.c" "${CCMAES_SRC_DIR}/boundary_transformation.c")
# Library to be compiled
add_library(ccmaes SHARED ${CCMAES_SRC})
# Link the library with the standard C lib for maths
target_link_libraries(ccmaes m)
# Examples
if(COMPILE_EXAMPLES)
# Examples executables will be put here
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/examples)
message(STATUS "Configuring examples")
# Grab the examples
add_executable(evoshort ${CCMAES_SRC_DIR}/example_short.c)
add_executable(evobounds ${CCMAES_SRC_DIR}/example_boundary.c)
# Link the executables with the existing ccmaes library and the standard C lib for maths
target_link_libraries(evoshort ccmaes m)
target_link_libraries(evobounds ccmaes m)
endif(COMPILE_EXAMPLES)