-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
143 lines (113 loc) · 4.71 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
##############################
###### ######
###### URL Shortener ######
###### ######
##############################
cmake_minimum_required(VERSION 3.14.0)
if(NOT APPLE)
message(FATAL_ERROR "Unfortunetly only MacOS is supported.")
endif()
set(MACOSX_COMPILER "libcxx-min10.14")
set(MACOSX_SYSTEM_ID "MacOSX-x86-64")
project(URLShortener
VERSION 0.0.1
DESCRIPTION "A simple API to parse long URL to a shorter version, and retrieve the longer version from the latter."
LANGUAGES CXX
)
set(PROJECT_NAME URLShortener)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "Install prefix" FORCE)
endif()
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "None" "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
set(CMAKE_VERBOSE_MAKEFILE OFF CACHE BOOL "Verbose")
if(NOT TARGET URLShortener)
set(THIRDPARTY_LOCATION "${CMAKE_INSTALL_PREFIX}/ThirdPartyDependencies")
if(NOT EXISTS ${THIRDPARTY_LOCATION})
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/Auxiliary/ThirdPartyDependencies.tar.gz")
message(STATUS "Unpacking 3rd party dependencies...")
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xzf "${CMAKE_CURRENT_SOURCE_DIR}/Auxiliary/ThirdPartyDependencies.tar.gz"
WORKING_DIRECTORY ${CMAKE_INSTALL_PREFIX}
)
endif()
endif()
#=============================================
#==================== ZLIB ===================
#=============================================
find_library(Z_LIBRARY
NAMES z
)
if(${Z_LIBRARY} STREQUAL Z_LIBRARY-NOTFOUND)
message(FATAL_ERROR "libz not found.")
endif()
#=============================================
#=================== Served ==================
#=============================================
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake)
set(SERVED_VERSION "1.0.0")
set(SERVED_BINARY_LOCATION "${THIRDPARTY_LOCATION}/Served/${SERVED_VERSION}/${MACOSX_SYSTEM_ID}/${MACOSX_COMPILER}/Lib")
set(SERVED_INCLUDE_LOCATION "${THIRDPARTY_LOCATION}/Served/${SERVED_VERSION}/${MACOSX_SYSTEM_ID}/${MACOSX_COMPILER}/Include")
include_directories(${SERVED_INCLUDE_LOCATION})
find_library(SERVED_LIBRARY
NAMES served
PATHS ${SERVED_BINARY_LOCATION}
NO_DEFAULT_PATH
)
if(${SERVED_LIBRARY} STREQUAL SERVED_LIBRARY-NOTFOUND)
message(FATAL_ERROR "libserved.a not found.")
endif()
#=============================================
#================== Crypto++ =================
#=============================================
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake)
set(CRYPTO_VERSION "8.6")
set(CRYPTO_BINARY_LOCATION "${THIRDPARTY_LOCATION}/Crypto++/${CRYPTO_VERSION}/${MACOSX_SYSTEM_ID}/${MACOSX_COMPILER}/Lib")
set(CRYPTO_INCLUDE_LOCATION "${THIRDPARTY_LOCATION}/Crypto++/${CRYPTO_VERSION}/${MACOSX_SYSTEM_ID}/${MACOSX_COMPILER}/Include")
include_directories(${CRYPTO_INCLUDE_LOCATION})
find_library(CRYPTO_LIBRARY
NAMES cryptopp
PATHS ${CRYPTO_BINARY_LOCATION}
NO_DEFAULT_PATH
)
if(${CRYPTO_LIBRARY} STREQUAL CRYPTO_LIBRARY-NOTFOUND)
message(FATAL_ERROR "libcryptopp.a not found.")
endif()
#=============================================
#=================== Boost ===================
#=============================================
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMake)
set(BOOST_VERSION "1.78.0")
set(BOOST_BINARY_LOCATION "${THIRDPARTY_LOCATION}/Boost/${BOOST_VERSION}/${MACOSX_SYSTEM_ID}/${MACOSX_COMPILER}/Lib")
set(BOOST_INCLUDE_LOCATION "${THIRDPARTY_LOCATION}/Boost/${BOOST_VERSION}/${MACOSX_SYSTEM_ID}/${MACOSX_COMPILER}/Include")
include_directories(${BOOST_INCLUDE_LOCATION})
find_library(BOOST-JSON_LIBRARY
NAMES boost_json
PATHS ${BOOST_BINARY_LOCATION}
NO_DEFAULT_PATH
)
if(${BOOST-JSON_LIBRARY} STREQUAL BOOST-JSON_LIBRARY-NOTFOUND)
message(FATAL_ERROR "libboost_json.a not found.")
endif()
find_library(BOOST-UNIT-TEST_LIBRARY
NAMES boost_unit_test_framework
PATHS ${BOOST_BINARY_LOCATION}
NO_DEFAULT_PATH
)
if(${BOOST-UNIT-TEST_LIBRARY} STREQUAL BOOST-UNIT-TEST_LIBRARY-NOTFOUND)
message(FATAL_ERROR "libboost_unit_test_framework.a not found.")
endif()
#=============================================
#============== MAIN LIBRARY =================
#=============================================
set_source_files_properties(
PROPERTIES
EXTERNAL_OBJECT true
GENERATED true
)
include(${CMAKE_CURRENT_SOURCE_DIR}/Sources/Sources.cmake)
setup_url_target(FALSE)
setup_url_target(TRUE)
include(${CMAKE_CURRENT_SOURCE_DIR}/Tests/Tests.cmake)
setup_test_target(TRUE)
endif() #end IF NOT TARGET URLShortener