-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
54 lines (45 loc) · 1.65 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
cmake_minimum_required(VERSION 3.28)
project(primal
VERSION 0.1.0
DESCRIPTION "Computes prime numbers using a Sieve of Eratosthenes."
HOMEPAGE_URL "https://github.com/fiffy326/primal"
LANGUAGES CXX)
# Set the C++ standard
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Require out-of-source builds
file(TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" LOC_PATH)
if (EXISTS "${LOC_PATH}")
message(FATAL_ERROR "You cannot build in a source directory.\
Please create a build subdirectory.")
endif ()
# Include CMake modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(CompilerFlags)
# Include the src directory
add_subdirectory(src)
# Include the docs directory
find_package(Doxygen)
if (Doxygen_FOUND)
add_subdirectory(docs)
else ()
message(STATUS "Doxygen not found, not building docs")
endif ()
# Configure version.hpp
configure_file(
${PROJECT_SOURCE_DIR}/cmake/version.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/version.hpp @ONLY)
# Configure the manpage
configure_file(
${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}.1.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.1 @ONLY)
# Install rules
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.1
DESTINATION share/man/man1)
# Uninstall target
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_INSTALL_PREFIX}/bin/${PROJECT_NAME}
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_INSTALL_PREFIX}/share/man/man1/${PROJECT_NAME}.1
COMMENT "Removing installed files")