|
1 | 1 | # -*- shell-script -*- make up a mode for emacs
|
2 |
| -# CMake setup primarily by Roland Arsenault - https://github.com/rolker/libais |
3 | 2 |
|
4 | 3 | # To use cmake:
|
5 |
| - |
| 4 | +# |
6 | 5 | # cmake .
|
7 | 6 | # make
|
8 | 7 |
|
9 | 8 | cmake_minimum_required (VERSION 2.8)
|
10 | 9 | project (libais)
|
11 | 10 |
|
12 |
| -#include_directories("${PROJECT_BINARY_DIR}") |
13 |
| - |
14 |
| -set (HEADERS |
15 |
| - ais.h |
16 |
| -) |
17 |
| - |
18 |
| -set (SOURCES |
19 |
| - ais |
20 |
| - ais1_2_3 |
21 |
| - ais4_11 |
22 |
| - ais5 |
23 |
| - ais7_13 |
24 |
| - ais8 ais8_1_22 ais8_1_26 ais8_366_22 |
25 |
| - ais9 |
26 |
| - ais10 # : |
27 |
| - # ais11 ; - See 4 |
28 |
| - ais12 # < |
29 |
| - # ais13 = See 7 |
30 |
| - ais14 # > |
31 |
| - ais15 # ? |
32 |
| - ais16 # @ |
33 |
| - ais17 # A |
34 |
| - ais18 # B |
35 |
| - ais19 # C |
36 |
| - ais20 # D |
37 |
| - ais21 # E |
38 |
| - ais22 # F |
39 |
| - ais23 # G |
40 |
| - ais24 # H |
41 |
| - ais25 # I |
42 |
| - ais26 # J |
43 |
| - ais27 # K |
44 |
| - # ais28 # L - Not yet defined |
45 |
| -) |
46 |
| - |
47 |
| -install(FILES ${HEADERS} DESTINATION include) |
48 |
| - |
49 |
| -add_library(ais STATIC ${SOURCES} ) |
50 |
| -install(TARGETS ais DESTINATION lib) |
51 |
| - |
52 |
| -option(AIS_PYTHON "Build python bindings" ON) |
53 |
| - |
54 |
| -if(AIS_PYTHON) |
55 |
| - find_package(PythonInterp REQUIRED) |
56 |
| - set (PYTHON_SOURCES ${SOURCES} ais_py.cpp) |
57 |
| - add_custom_target(python_build ALL ${PYTHON_EXECUTABLE} setup.py build --build-base ${CMAKE_BINARY_DIR}/python |
58 |
| - DEPENDS ${SOURCES} |
59 |
| - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} |
60 |
| - COMMENT "python build" |
61 |
| - SOURCES ${PYTHON_SOURCES} |
62 |
| - ) |
63 |
| - |
64 |
| - install(CODE "message(\"python install\")\n execute_process(COMMAND ${PYTHON_EXECUTABLE} setup.py -q build --build-base ${CMAKE_BINARY_DIR}/python install --prefix ${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})") |
| 11 | +include(CheckCXXCompilerFlag) |
| 12 | +CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) |
| 13 | +CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X) |
| 14 | +if(COMPILER_SUPPORTS_CXX11) |
| 15 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") |
| 16 | +elseif(COMPILER_SUPPORTS_CXX0X) |
| 17 | + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") |
| 18 | +else() |
| 19 | + message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") |
65 | 20 | endif()
|
66 | 21 |
|
67 |
| -# testing support |
68 |
| - |
69 |
| -option(BUILD_TESTS "Enable testing." OFF) |
70 |
| - |
71 |
| -if(BUILD_TESTS) |
| 22 | +# include_directories("${PROJECT_BINARY_DIR}/src/libais") |
72 | 23 |
|
73 |
| - option(TESTS_NEED_PTHREADS "Enable if tests need to link agains pthreads" OFF) |
74 |
| - option(SEPARATE_TESTS "Enable if separate tests should be built, otherwise a single test executable will be built containing all tests" ON) |
| 24 | +add_subdirectory(src) |
75 | 25 |
|
76 |
| - find_path(gtest_INCLUDE_DIR gtest/test.h) |
77 |
| - find_library(gtest_LIBRARY gtest) |
78 |
| - find_library(gtest_main_LIBRARY gtest_main) |
79 |
| - |
80 |
| - if(gtest_INCLUDE_DIR AND gtest_LIBRARY AND gtest_main_LIBRARY) |
81 |
| - include_directories(${gtest_INCLUDE_DIR}) |
82 |
| - set(TEST_LIBS ${TEST_LIBS} ${gtest_LIBRARY} ${gtest_main_LIBRARY}) |
83 |
| - else() |
84 |
| - message(FATAL_ERROR "gtest not found") |
85 |
| - endif() |
86 |
| - |
87 |
| - if(TESTS_NEED_PTHREADS) |
88 |
| - find_package(Threads) |
89 |
| - if(CMAKE_THREAD_LIBS_INIT AND CMAKE_USE_PTHREADS_INIT) |
90 |
| - set(TEST_LIBS ${TEST_LIBS} ${CMAKE_THREAD_LIBS_INIT}) |
91 |
| - else() |
92 |
| - message(FATAL_ERROR "pthreads not found") |
93 |
| - endif() |
94 |
| - endif() |
95 |
| - |
96 |
| - set (TEST_SOURCES |
97 |
| - ais1_2_3_unittest |
98 |
| - ais8_1_22_unittest |
99 |
| - ais8_200_10_unittest |
100 |
| - ) |
101 |
| - |
102 |
| - enable_testing() |
103 |
| - |
104 |
| - if(SEPARATE_TESTS) |
105 |
| - foreach(TEST_SOURCE ${TEST_SOURCES}) |
106 |
| - add_executable(${TEST_SOURCE} ${TEST_SOURCE}) |
107 |
| - target_link_libraries (${TEST_SOURCE} ais ${TEST_LIBS}) |
108 |
| - add_test(${TEST_SOURCE} ${TEST_SOURCE}) |
109 |
| - endforeach() |
110 |
| - else() |
111 |
| - add_executable(all_tests ${TEST_SOURCES}) |
112 |
| - target_link_libraries(all_tests ais ${TEST_LIBS}) |
113 |
| - add_test(all_tests all_tests) |
114 |
| - endif() |
115 |
| - |
116 |
| -endif() |
117 |
| - |
118 |
| -option(BUILD_OLD_TESTS "Enable old testing code." OFF) |
119 |
| - |
120 |
| -if(BUILD_OLD_TESTS) |
121 |
| - add_executable(test_libais test_libais.cpp) |
122 |
| - target_link_libraries(test_libais ais) |
123 |
| - add_test(test_libais test_libais) |
124 |
| -endif() |
0 commit comments