forked from matheusgomes28/base64pp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
71 lines (58 loc) · 2.58 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
cmake_minimum_required(VERSION 3.16)
project(Base64pp LANGUAGES CXX)
# Must compile with C++20, no
# extensions
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN On)
if(NOT WIN32 AND CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
if (NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "/opt/${PROJECT_NAME}")
endif()
endif()
option(BUILD_DOCS "Build documentation" Off)
option(BUILD_SHARED "Build shared library" Off)
option(BUILD_TESTS "Build tests with google tests" Off)
add_subdirectory(base64pp)
if (BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
endif()
if (BUILD_DOCS)
find_package(Doxygen)
set(DOXYGEN_IN ${CMAKE_CURRENT_LIST_DIR}/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_LIST_DIR}/Doxyfile)
set(DOXYGEN_STYLESHEET_DIR "${CMAKE_CURRENT_LIST_DIR}/doxygen-awesome-css")
set(DOXYGEN_OUTPUT_DIR "${CMAKE_BINARY_DIR}/docs")
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
if (DOXYGEN_FOUND)
# note the option ALL which allows to build the docs together with the application
add_custom_target(doxygen_build
COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_LIST_DIR}/Doxyfile"
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM)
file(GLOB DOXYGEN_STYLESHEET_FILES ${CMAKE_CURRENT_LIST_DIR}/doxygen-awesome-css/*.css)
file(GLOB DOXYGEN_JAVASCRIPT_FILES ${CMAKE_CURRENT_LIST_DIR}/doxygen-awesome-css/*.js)
add_custom_target(copy_doxygen_css)
foreach(F ${DOXYGEN_STYLESHEET_FILES})
get_filename_component(F_NAME ${F} NAME)
add_custom_command(TARGET copy_doxygen_css
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${F} ${DOXYGEN_OUTPUT_DIR}/html/${F_NAME})
endforeach()
add_dependencies(doxygen_build copy_doxygen_css)
add_custom_target(copy_doxygen_js)
foreach(F ${DOXYGEN_JAVASCRIPT_FILES})
get_filename_component(F_NAME ${F} NAME)
add_custom_command(TARGET copy_doxygen_js
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${F} ${DOXYGEN_OUTPUT_DIR}/html/${F_NAME})
endforeach()
add_dependencies(doxygen_build copy_doxygen_js)
else()
message("Doxygen need to be installed to generate the doxygen documentation")
endif()
endif()