-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
79 lines (68 loc) · 3.73 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
### make sure the user is doing an our of source build:
if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
message( FATAL_ERROR "In-source builds are not allowed. use cmake -H. -Bbuild instead to build in the build folder" )
endif()
###
cmake_minimum_required (VERSION 2.6)
project (npmc C)
# set the compiler with its flags
# SET(CMAKE_C_COMPILER gcc)
SET(CMAKE_BUILD_TYPE Release)
if(NOT MSVC)
set(CMAKE_C_FLAGS_DEBUG "-g -O0 -Wall -Wextra -fprofile-arcs -ftest-coverage")
set(CMAKE_C_FLAGS_RELEASE "-g -O0 -ffast-math -Wall -Wextra -Wno-unused-parameter -fprofile-arcs -ftest-coverage")
set(LDFLAGS "-O0 -fprofile-arcs -ftest-coverage")
SET(CMAKE_EXE_LINKER_FLAGS="-fprofile-arcs -ftest-coverage")
endif()
# subdirectories with libraries
include_directories ("${PROJECT_SOURCE_DIR}/PANOC")
add_subdirectory (PANOC) # read out the cmakelist file
include_directories ("${PROJECT_SOURCE_DIR}/casadi")
add_subdirectory (casadi)
# add the python interface, this target is excluded from all
if(WIN32)
SET(TIMER_LIB "${PROJECT_SOURCE_DIR}/python_interface/timer_windows.c")
elseif(APPLE )
SET(TIMER_LIB "${PROJECT_SOURCE_DIR}/python_interface/timer_empty.c" ) # TODO add timer class for mac's
else()
SET(TIMER_LIB "${PROJECT_SOURCE_DIR}/python_interface/timer_linux.c" )
endif()
add_library(python_interface SHARED "${PROJECT_SOURCE_DIR}/python_interface/nmpc_python" "${TIMER_LIB}")
target_link_libraries (python_interface PANOC_lib)
target_link_libraries (python_interface CASADI_lib)
set_property(TARGET python_interface PROPERTY C_STANDARD 90)
set_property(TARGET python_interface PROPERTY POSITION_INDEPENDENT_CODE ON)
set_property(TARGET python_interface PROPERTY EXCLUDE_FROM_ALL TRUE)
# Test the functionality
enable_testing()
add_subdirectory(tst)
# Tests on the matrix/vector operations
add_test(NAME matrix_operations_norms COMMAND tst/matrix_operations_norms)
add_test(NAME matrix_operations_vectors COMMAND tst/matrix_operations_vectors)
add_test(NAME lbfgs_poly_test COMMAND tst/lbfgs_poly_test)
#add_test(NAME lipschitz_estimator_test COMMAND tst/lipschitz_estimator_test)
add_test(NAME prox_grad_descent_poly_test COMMAND tst/prox_grad_descent_poly_test)
add_test(NAME panoc_poly_test COMMAND tst/panoc_poly_test)
#add_test(NAME casadi_interface_test COMMAND tst/casadi_interface_test)
add_custom_target(gcov
COMMAND mkdir -p coverage
COMMAND ${CMAKE_MAKE_PROGRAM} test
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_dependencies(gcov matrix_operations_norms)
add_dependencies(gcov matrix_operations_vectors)
add_dependencies(gcov lbfgs_poly_test)
#add_dependencies(gcov lipschitz_estimator_test)
add_dependencies(gcov prox_grad_descent_poly_test)
add_dependencies(gcov panoc_poly_test)
#add_dependencies(gcov casadi_interface_test)
add_custom_command(TARGET gcov
COMMAND echo "=================== GCOV ===================="
COMMAND gcov-4.8 -b ${CMAKE_SOURCE_DIR}/PANOC/*.c -o "${CMAKE_BINARY_DIR}/tst/CMakeFiles/matrix_operations_norms.dir/src/matrix_operations_norms.c.gcno"
COMMAND gcov-4.8 -b ${CMAKE_SOURCE_DIR}/PANOC/*.c -o "${CMAKE_BINARY_DIR}/tst/CMakeFiles/matrix_operations_vectors.dir/src/matrix_operations_vectors.c.gcno"
COMMAND gcov-4.8 -b ${CMAKE_SOURCE_DIR}/PANOC/*.c -o "${CMAKE_BINARY_DIR}/tst/CMakeFiles/lbfgs_poly_test.dir/src/lbfgs_poly_test.c.gcno"
COMMAND gcov-4.8 -b ${CMAKE_SOURCE_DIR}/PANOC/*.c -o "${CMAKE_BINARY_DIR}/tst/CMakeFiles/prox_grad_descent_poly_test.dir/src/prox_grad_descent_poly_test.c.gcno"
COMMAND gcov-4.8 -b ${CMAKE_SOURCE_DIR}/PANOC/*.c -o "${CMAKE_BINARY_DIR}/tst/CMakeFiles/panoc_poly_test.dir/src/panoc_poly_test.c.gcno"
COMMAND echo "-- Coverage files have been output to ${CMAKE_BINARY_DIR}/coverage"
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/coverage
)