Skip to content

Commit 7bfd064

Browse files
committed
Starting over on cmake support
1 parent 410af69 commit 7bfd064

File tree

4 files changed

+60
-111
lines changed

4 files changed

+60
-111
lines changed

CMakeLists.txt

Lines changed: 12 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,25 @@
11
# -*- shell-script -*- make up a mode for emacs
2-
# CMake setup primarily by Roland Arsenault - https://github.com/rolker/libais
32

43
# To use cmake:
5-
4+
#
65
# cmake .
76
# make
87

98
cmake_minimum_required (VERSION 2.8)
109
project (libais)
1110

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.")
6520
endif()
6621

67-
# testing support
68-
69-
option(BUILD_TESTS "Enable testing." OFF)
70-
71-
if(BUILD_TESTS)
22+
# include_directories("${PROJECT_BINARY_DIR}/src/libais")
7223

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)
7525

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()

Makefile-custom

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ real-clean: clean
5252
rm -f MANIFEST
5353
rm -rf build dist
5454
find . -name .DS_Store | xargs rm -f
55+
rm -f test/typeexamples.gpsdecode.json
56+
find . -name \*.o | xargs rm
57+
find . -name \*.a | xargs rm
58+
echo "cmake files:"
59+
rm -rf CMakeCache.txt
60+
rm -f Makefile
61+
find src -name Makefile | xargs rm
62+
find . -name cmake_install.cmake | xargs rm
63+
find . -name CMakeFiles | xargs rm -rf
64+
5565

5666
.PHONY: test
5767
test:

src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
add_subdirectory(libais)

src/libais/CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
add_library(ais
3+
ais.cpp
4+
ais1_2_3.cpp
5+
ais4_11.cpp
6+
ais5.cpp
7+
ais6.cpp
8+
ais7_13.cpp
9+
ais8.cpp
10+
ais8_1_22.cpp
11+
ais8_1_26.cpp
12+
ais8_200.cpp
13+
ais8_366.cpp
14+
ais8_366_22.cpp
15+
ais8_367.cpp
16+
ais9.cpp
17+
ais10.cpp
18+
ais12.cpp
19+
ais14.cpp
20+
ais15.cpp
21+
ais16.cpp
22+
ais17.cpp
23+
ais18.cpp
24+
ais19.cpp
25+
ais20.cpp
26+
ais21.cpp
27+
ais22.cpp
28+
ais23.cpp
29+
ais24.cpp
30+
ais25.cpp
31+
ais26.cpp
32+
ais27.cpp
33+
)
34+
35+
# Not yet handled:
36+
# ais_py.cpp
37+
# ais_decode_normed.cpp

0 commit comments

Comments
 (0)