40e6972fe1e762a805e6ebebc6006cef21c818bf
[cppcodec.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8)
2 project(cppcodec)
3
4 option(build_tests "Build tests (run as 'test' target)" ON)
5
6 # These flags are for binaries built by this particular CMake project (test_cppcodec, base64enc, etc.).
7 # In your own project that uses cppcodec, you might want to specify a different standard or error level.
8 if (MSVC)
9   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3")
10 else()
11   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -pedantic")
12 endif()
13
14 set(PUBLIC_HEADERS
15     # base32
16     cppcodec/base32_crockford.hpp
17     cppcodec/base32_default_crockford.hpp
18     cppcodec/base32_default_hex.hpp
19     cppcodec/base32_default_rfc4648.hpp
20     cppcodec/base32_hex.hpp
21     cppcodec/base32_rfc4648.hpp
22     # base64
23     cppcodec/base64_default_rfc4648.hpp
24     cppcodec/base64_default_url.hpp
25     cppcodec/base64_default_url_unpadded.hpp
26     cppcodec/base64_rfc4648.hpp
27     cppcodec/base64_url.hpp
28     cppcodec/base64_url_unpadded.hpp
29     # hex
30     cppcodec/hex_default_lower.hpp
31     cppcodec/hex_default_upper.hpp
32     cppcodec/hex_lower.hpp
33     cppcodec/hex_upper.hpp
34     # other stuff
35     cppcodec/parse_error.hpp
36     cppcodec/data/access.hpp
37     cppcodec/data/raw_result_buffer.hpp
38     cppcodec/detail/base32.hpp
39     cppcodec/detail/base64.hpp
40     cppcodec/detail/codec.hpp
41     cppcodec/detail/config.hpp
42     cppcodec/detail/hex.hpp
43     cppcodec/detail/stream_codec.hpp)
44
45 add_library(cppcodec OBJECT ${PUBLIC_HEADERS}) # unnecessary for building, but makes headers show up in IDEs
46 set_target_properties(cppcodec PROPERTIES LINKER_LANGUAGE CXX)
47 add_subdirectory(tool)
48
49 if (build_tests)
50     enable_testing()
51     add_subdirectory(test)
52 endif()
53
54 foreach(h ${PUBLIC_HEADERS})
55     get_filename_component(HEADER_INCLUDE_DIRECTORY include/${h} PATH) # use DIRECTORY instead of PATH once requiring CMake 3.0
56     install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${h} DESTINATION ${HEADER_INCLUDE_DIRECTORY} COMPONENT "headers")
57 endforeach()