-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
114 lines (98 loc) · 4.28 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
cmake_minimum_required(VERSION 3.20)
project(Enigma VERSION "3.2.0" DESCRIPTION "A Simple, Reliable and Efficient Encryption Tool" LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
################# Options ###########################
option(ENIGMA_ENABLE_TESTS "Enable/Disable building of tests" OFF)
option(ENIGMA_BUILD_DOCS "Build Doxygen API documentation" OFF)
#####################################################
###### Doxygen Documentation ######
if (ENIGMA_BUILD_DOCS)
message(STATUS "Building Doxygen docs is enabled")
find_package(Doxygen REQUIRED)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile)
add_custom_target(enigma_build_docs ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating Doxygen API documentation..."
VERBATIM
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/docs/html/ TYPE DOC)
# No need to go further as we're only building docs.
return()
endif ()
###################################
################## Libraries ##########################
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/deps.cmake")
#######################################################
################## Main Project ##########################
file(GLOB_RECURSE ENIGMA_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/**.cpp")
file(GLOB_RECURSE ENIGMA_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/src/**.hpp")
if(ENIGMA_ENABLE_TESTS)
# Tests enabled? Build Enigma as a static lib so EnigmaTests will link with it.
# The compiler will ignore the main function as an unused non-special function.
add_library(${PROJECT_NAME} STATIC ${ENIGMA_SOURCES})
else ()
# Tests off? build Enigma as an application
add_executable(${PROJECT_NAME} ${ENIGMA_SOURCES})
endif ()
source_group("Headers" ${ENIGMA_HEADERS})
target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src" "${CMAKE_CURRENT_SOURCE_DIR}/res/fonts" "${CMAKE_CURRENT_SOURCE_DIR}/res/branding")
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_20)
target_precompile_headers(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src/pch.hpp")
target_compile_definitions(${PROJECT_NAME} PRIVATE
$<$<CONFIG:Debug>:ENIGMA_DEBUG>
$<$<CONFIG:Release>:ENIGMA_RELEASE>
)
target_compile_definitions(${PROJECT_NAME} PUBLIC
ENIGMA_VERSION="${PROJECT_VERSION}"
ENIGMA_VERSION_MINOR=${PROJECT_VERSION_MINOR}
ENIGMA_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}
ENIGMA_VERSION_PATCH=${PROJECT_VERSION_PATCH}
ENIGMA_DESCRIPTION="${PROJECT_DESCRIPTION}"
LOCAL_RES_DIR="${CMAKE_CURRENT_SOURCE_DIR}/res"
# CONFIG_DIR="${CMAKE_CURRENT_SOURCE_DIR}/res/config"
# FONTS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/res/fonts"
# BRANDING_DIR="${CMAKE_CURRENT_SOURCE_DIR}/res/branding"
# DATABASE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/res/database"
# LOGS_DIR="${CMAKE_CURRENT_SOURCE_DIR}/res/logs"
)
target_link_libraries(${PROJECT_NAME} PRIVATE
${ENIGMA_DEPENDENCIES}
)
####################################################
############ Platform macros ############
if (WIN32)
# No need, will be defined by Core/Platform.hpp
# target_compile_definitions(${PROJECT_NAME} PRIVATE ENIGMA_PLATFORM_WINDOWS)
# Use Enigma.rc resource file
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Enigma.rc.in ${CMAKE_CURRENT_BINARY_DIR}/Enigma.rc)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/Enigma.rc)
# Common MSVC warnings defines
if (MSVC)
target_compile_definitions(${PROJECT_NAME} PRIVATE
_CRT_SECURE_NO_DEPRECATE
_CRT_SECURE_NO_WARNINGS
_CRT_NONSTDC_NO_WARNINGS
)
elseif (MINGW)
target_compile_definitions(${PROJECT_NAME} PRIVATE
STRSAFE_NO_DEPRECATE # for strcpy_instead_use_StringCbCopyA_or_StringCchCopyA
)
endif ()
elseif (UNIX AND NOT APPLE)
# No need, will be defined by Core/Platform.hpp
# target_compile_definitions(${PROJECT_NAME} PRIVATE ENIGMA_PLATFORM_LINUX)
else ()
message(FATAL_ERROR "Unsupported platform")
endif ()
########################################
###### Tests ######
if (ENIGMA_ENABLE_TESTS)
message(STATUS "Building tests is enabled")
enable_testing()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests)
endif ()
####################
#### Install scripts ######
include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/install.cmake")