forked from cieslarmichal/faker-cxx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
146 lines (131 loc) · 4.5 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
cmake_minimum_required(VERSION 3.22)
project(faker-cxx LANGUAGES CXX)
include(cmake/CompilerWarnings.cmake)
option(USE_SYSTEM_DEPENDENCIES "Use fmt and GTest from system" OFF)
option(USE_STD_FORMAT "Use std::format when avaiable" ON)
option(BUILD_EXAMPLES "Build examples" OFF)
if (USE_STD_FORMAT)
set(CMAKE_REQUIRED_FLAGS -std=c++20)
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("#include <format>\nint main(){ auto var = std::format(\"{}\", \"Hello\"); return 0; }"
HAS_STD_FORMAT)
endif ()
if (BUILD_TESTING)
enable_testing()
set(target_code_coverage_ALL 1)
include("cmake/cmake-coverage.cmake")
add_code_coverage_all_targets()
endif ()
set(FAKER_SOURCES
src/modules/airline/Airline.cpp
src/modules/airline/AirlineData.cpp
src/modules/animal/Animal.cpp
src/modules/animal/AnimalData.cpp
src/modules/book/Book.cpp
src/modules/book/BookData.cpp
src/modules/color/Color.cpp
src/modules/color/ColorData.cpp
src/modules/commerce/Commerce.cpp
src/modules/commerce/CommerceData.cpp
src/modules/company/Company.cpp
src/modules/company/CompanyData.cpp
src/modules/computer/Computer.cpp
src/modules/computer/ComputerData.cpp
src/modules/crypto/Crypto.cpp
src/modules/database/Database.cpp
src/modules/database/DatabaseData.cpp
src/modules/datatype/Datatype.cpp
src/modules/date/Date.cpp
src/modules/date/DateData.cpp
src/modules/finance/Finance.cpp
src/modules/finance/FinanceData.cpp
src/modules/food/Food.cpp
src/modules/food/FoodData.cpp
src/modules/git/Git.cpp
src/modules/hacker/Hacker.cpp
src/modules/hacker/HackerData.cpp
src/modules/helper/Helper.cpp
src/modules/image/Image.cpp
src/modules/internet/Internet.cpp
src/modules/internet/InternetData.cpp
src/modules/location/Location.cpp
src/modules/location/LocationData.cpp
src/modules/lorem/Lorem.cpp
src/modules/lorem/LoremData.cpp
src/modules/medicine/Medicine.cpp
src/modules/medicine/MedicineData.cpp
src/modules/movie/Movie.cpp
src/modules/movie/MovieData.cpp
src/modules/music/Music.cpp
src/modules/music/MusicData.cpp
src/modules/number/Number.cpp
src/modules/person/Person.cpp
src/modules/person/PersonData.cpp
src/modules/phone/Phone.cpp
src/modules/phone/PhoneData.cpp
src/modules/plant/Plant.cpp
src/modules/plant/PlantData.cpp
src/modules/science/Science.cpp
src/modules/science/ScienceData.cpp
src/modules/sport/Sport.cpp
src/modules/sport/SportData.cpp
src/modules/string/String.cpp
src/modules/system/System.cpp
src/modules/vehicle/Vehicle.cpp
src/modules/vehicle/VehicleData.cpp
src/modules/videoGame/VideoGame.cpp
src/modules/videoGame/VideoGameData.cpp
src/modules/weather/Weather.cpp
src/modules/weather/WeatherData.cpp
src/modules/word/Word.cpp
src/common/FormatHelper.cpp
src/common/LuhnCheck.cpp
src/common/StringHelper.cpp
src/common/PrecisionMapper.cpp
)
add_library(${CMAKE_PROJECT_NAME} ${FAKER_SOURCES})
target_include_directories(
${CMAKE_PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_include_directories(
${CMAKE_PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
)
target_compile_features(${CMAKE_PROJECT_NAME} PUBLIC cxx_std_20)
configure_compiler_warnings(${CMAKE_PROJECT_NAME}
"${WARNINGS_AS_ERRORS}"
"${MSVC_WARNINGS}"
"${CLANG_WARNINGS}"
"${GCC_WARNINGS}")
include(GNUInstallDirs)
install(TARGETS ${CMAKE_PROJECT_NAME}
EXPORT ${CMAKE_PROJECT_NAME}-targets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/faker-cxx
DESTINATION include/
FILES_MATCHING
PATTERN "*.h"
)
install(EXPORT ${CMAKE_PROJECT_NAME}-targets
NAMESPACE ${CMAKE_PROJECT_NAME}::
FILE ${CMAKE_PROJECT_NAME}-config.cmake
DESTINATION lib/cmake/${CMAKE_PROJECT_NAME})
if (HAS_STD_FORMAT)
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE HAS_STD_FORMAT)
elseif (USE_SYSTEM_DEPENDENCIES)
find_package(fmt REQUIRED)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE fmt::fmt)
else ()
add_subdirectory(externals/fmt)
set(FMT_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/fmt/include")
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE fmt)
endif ()
if (BUILD_TESTING)
add_subdirectory(tests)
endif ()
if (BUILD_EXAMPLES)
add_subdirectory(examples)
endif ()