1
1
2
- cmake_minimum_required ( VERSION 2.6 )
3
- project ( scitokens-cpp )
2
+ cmake_minimum_required ( VERSION 3.10)
4
3
5
- option ( BUILD_UNITTESTS "Build the scitokens-cpp unit tests" OFF )
6
- option ( EXTERNAL_GTEST "Use an external/pre-installed copy of GTest" OFF )
4
+ project ( scitokens-cpp
5
+ DESCRIPTION "A C++ Library to interface to scitokens"
6
+ VERSION 0.7.0
7
+ LANGUAGES CXX)
7
8
8
- set ( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR} /cmake )
9
+ option ( SCITOKENS_BUILD_UNITTESTS "Build the scitokens-cpp unit tests" OFF )
10
+ option ( SCITOKENS_EXTERNAL_GTEST "Use an external/pre-installed copy of GTest" OFF )
11
+ option ( SCTOKENS_WARNINGS_ARE_ERRORS "Turn compiler warnings into build errors" OFF )
12
+
13
+ set ( CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR} /cmake;${CMAKE_MODULE_PATH} " )
14
+
15
+ set ( CMAKE_BUILD_TYPE RelWithDebInfo) # -g -O2
9
16
10
17
include (GNUInstallDirs)
11
18
12
19
find_package ( jwt-cpp REQUIRED )
13
20
find_package ( CURL REQUIRED )
14
21
find_package ( UUID REQUIRED )
15
22
16
- if ( CMAKE_COMPILER_IS_GNUCXX )
17
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror" )
18
- endif ()
19
-
20
- if ( CMAKE_COMPILER_IS_GNUCC )
21
- set (CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror" )
22
- endif ()
23
-
24
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
25
- set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g" )
26
-
27
-
28
23
if ( APPLE )
29
24
30
25
find_package ( OpenSSL REQUIRED )
@@ -40,34 +35,45 @@ pkg_check_modules(LIBCRYPTO REQUIRED libcrypto)
40
35
pkg_check_modules(OPENSSL REQUIRED openssl)
41
36
pkg_check_modules(SQLITE REQUIRED sqlite3)
42
37
43
- # pkg_check_modules fails to return an absolute path on RHEL7. Set the
44
- # link directories accordingly.
45
- link_directories (${OPENSSL_LIBRARY_DIRS} ${LIBCRYPTO_LIBRARY_DIRS} )
46
38
endif ()
47
39
48
- include_directories ( "${PROJECT_SOURCE_DIR} " ${JWT_CPP_INCLUDES} ${CURL_INCLUDES} ${OPENSSL_INCLUDE_DIRS} ${LIBCRYPTO_INCLUDE_DIRS} ${SQLITE_INCLUDE_DIRS} ${UUID_INCLUDE_DIRS} )
49
-
50
40
add_library (SciTokens SHARED src/scitokens.cpp src/scitokens_internal.cpp src/scitokens_cache.cpp)
51
- target_link_libraries (SciTokens ${OPENSSL_LIBRARIES} ${LIBCRYPTO_LIBRARIES} ${CURL_LIBRARIES} ${SQLITE_LIBRARIES} ${UUID_LIBRARIES} )
41
+ target_compile_features (SciTokens PUBLIC cxx_std_11) # Use at least C++11 for building and when linking to scitokens
42
+ target_compile_options (SciTokens PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wall $<$<BOOL :${SCITOKENS_WARNINGS_ARE_ERRORS} >:-Werror>>)
43
+ target_include_directories (SciTokens PUBLIC ${JWT_CPP_INCLUDES} "${PROJECT_SOURCE_DIR} /src" PRIVATE ${CURL_INCLUDES} ${OPENSSL_INCLUDE_DIRS} ${LIBCRYPTO_INCLUDE_DIRS} ${SQLITE_INCLUDE_DIRS} ${UUID_INCLUDE_DIRS} )
44
+
45
+ target_link_libraries (SciTokens PUBLIC ${OPENSSL_LIBRARIES} ${LIBCRYPTO_LIBRARIES} ${CURL_LIBRARIES} ${SQLITE_LIBRARIES} ${UUID_LIBRARIES} )
46
+ if (UNIX )
47
+ # pkg_check_modules fails to return an absolute path on RHEL7. Set the
48
+ # link directories accordingly.
49
+ target_link_directories (SciTokens PUBLIC ${OPENSSL_LIBRARY_DIRS} ${LIBCRYPTO_LIBRARY_DIRS} )
50
+ endif ()
52
51
53
52
if ( NOT APPLE AND UNIX )
54
53
set_target_properties (SciTokens PROPERTIES LINK_FLAGS "-Wl,--version-script=${PROJECT_SOURCE_DIR} /configs/export-symbols" )
55
54
endif ()
56
55
57
56
add_executable (scitokens-test src/test .cpp)
57
+ #target_include_directories(scitokens-test PRIVATE "${PROJECT_SOURCE_DIR}" ${JWT_CPP_INCLUDES} ${CURL_INCLUDES} ${OPENSSL_INCLUDE_DIRS} ${LIBCRYPTO_INCLUDE_DIRS} ${SQLITE_INCLUDE_DIRS} ${UUID_INCLUDE_DIRS})
58
+ target_include_directories (scitokens-test PRIVATE "${PROJECT_SOURCE_DIR} " ${JWT_CPP_INCLUDES} )
58
59
target_link_libraries (scitokens-test SciTokens)
60
+ target_compile_options (scitokens-test PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wall $<$<BOOL :${SCITOKENS_WARNINGS_ARE_ERRORS} >:-Werror>>)
59
61
60
62
add_executable (scitokens-verify src/verify.cpp)
61
63
target_link_libraries (scitokens-verify SciTokens)
64
+ target_compile_options (scitokens-verify PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wall $<$<BOOL :${SCITOKENS_WARNINGS_ARE_ERRORS} >:-Werror>>)
62
65
63
66
add_executable (scitokens-test -access src/test_access.cpp)
64
67
target_link_libraries (scitokens-test -access SciTokens)
68
+ target_compile_options (scitokens-test -access PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wall $<$<BOOL :${SCITOKENS_WARNINGS_ARE_ERRORS} >:-Werror>>)
65
69
66
70
add_executable (scitokens-list-access src/list_access.cpp)
67
71
target_link_libraries (scitokens-list-access SciTokens)
72
+ target_compile_options (scitokens-list-access PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wall $<$<BOOL :${SCITOKENS_WARNINGS_ARE_ERRORS} >:-Werror>>)
68
73
69
74
add_executable (scitokens-create src/create.cpp)
70
75
target_link_libraries (scitokens-create SciTokens)
76
+ target_compile_options (scitokens-create PRIVATE $<$<CXX_COMPILER_ID:GNU>:-Wall $<$<BOOL :${SCITOKENS_WARNINGS_ARE_ERRORS} >:-Werror>>)
71
77
72
78
get_directory_property (TARGETS BUILDSYSTEM_TARGETS)
73
79
install (
@@ -86,8 +92,8 @@ set_target_properties(
86
92
SOVERSION "0"
87
93
)
88
94
89
- if ( BUILD_UNITTESTS )
90
- if ( NOT EXTERNAL_GTEST )
95
+ if ( SCITOKENS_BUILD_UNITTESTS )
96
+ if ( NOT SCITOKENS_EXTERNAL_GTEST )
91
97
include (ExternalProject)
92
98
ExternalProject_Add(gtest
93
99
PREFIX external/gtest
0 commit comments