|
1 | | -cmake_minimum_required (VERSION 2.8.0 FATAL_ERROR) |
2 | | -project (TAOCPP_OPERATORS) |
| 1 | +cmake_minimum_required (VERSION 3.2.0 FATAL_ERROR) |
3 | 2 |
|
4 | | -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") |
5 | | - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8 /W4 /WX") |
6 | | -elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") |
7 | | - set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") |
8 | | - set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG") |
9 | | - set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g") |
10 | | - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Werror") |
11 | | -elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") |
12 | | - set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") |
13 | | - set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG") |
14 | | - set (CMAKE_CXX_FLAGS_DEBUG "-O0 -g") |
15 | | - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Werror") |
16 | | -else () |
17 | | - message (FATAL_ERROR "Unknown C++ compiler") |
18 | | -endif () |
| 3 | +# set project and version |
| 4 | +project (taocpp-operators VERSION 1.0.0 LANGUAGES CXX) |
| 5 | + |
| 6 | +# define a header-only library |
| 7 | +add_library (taocpp-operators INTERFACE) |
| 8 | +add_library (taocpp::operators ALIAS taocpp-operators) |
| 9 | +target_include_directories (taocpp-operators INTERFACE |
| 10 | + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 11 | + $<INSTALL_INTERFACE:include> |
| 12 | +) |
19 | 13 |
|
| 14 | +# features used by taocpp/operators |
| 15 | +target_compile_features (taocpp-operators INTERFACE |
| 16 | + cxx_noexcept |
| 17 | + cxx_rvalue_references |
| 18 | +) |
| 19 | + |
| 20 | +# testing |
20 | 21 | enable_testing () |
| 22 | +option (TAOCPP_OPERATORS_BUILD_TESTS "Build test programs" ON) |
| 23 | +if (TAOCPP_OPERATORS_BUILD_TESTS) |
| 24 | + add_subdirectory (src/test/operators) |
| 25 | +endif () |
21 | 26 |
|
22 | | -include_directories (${CMAKE_SOURCE_DIR}/include) |
| 27 | +# installation directories |
| 28 | +set (TAOCPP_OPERATORS_INSTALL_INCLUDE_DIR "include" CACHE STRING "The installation include directory") |
| 29 | +set (TAOCPP_OPERATORS_INSTALL_DOC_DIR "share/doc/tao/operators" CACHE STRING "The installation doc directory") |
23 | 30 |
|
24 | | -file (GLOB testsources src/test/operators/*.cpp) |
25 | | -foreach (testsourcefile ${testsources}) |
26 | | - get_filename_component (exename ${testsourcefile} NAME_WE) |
27 | | - add_executable (${exename} ${testsourcefile}) |
28 | | - add_test (NAME ${exename} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${CMAKE_BINARY_DIR}/${exename}) |
29 | | -endforeach (testsourcefile) |
| 31 | +# install |
| 32 | +install (DIRECTORY include/ DESTINATION ${TAOCPP_OPERATORS_INSTALL_INCLUDE_DIR}) |
| 33 | +install (FILES LICENSE DESTINATION ${TAOCPP_OPERATORS_INSTALL_DOC_DIR}) |
0 commit comments