Update CMakeLists
This commit is contained in:
parent
d8197361fe
commit
c3e2552198
3 changed files with 44 additions and 31 deletions
|
@ -2,25 +2,34 @@
|
||||||
# refer to the root source directory of the project as ${HELLO_SOURCE_DIR} and
|
# refer to the root source directory of the project as ${HELLO_SOURCE_DIR} and
|
||||||
# to the root binary directory of the project as ${HELLO_BINARY_DIR}.
|
# to the root binary directory of the project as ${HELLO_BINARY_DIR}.
|
||||||
|
|
||||||
cmake_minimum_required (VERSION 2.8.11)
|
cmake_minimum_required(VERSION 3.1)
|
||||||
project (cpp-jwt)
|
project(cpp-jwt)
|
||||||
|
|
||||||
#SET (CMAKE_CXX_COMPILER /usr/local/bin/g++)
|
#SET (CMAKE_CXX_COMPILER /usr/local/bin/g++)
|
||||||
SET( CMAKE_CXX_FLAGS "-std=c++14 -Wall -Wextra" )
|
# SET( CMAKE_CXX_FLAGS "-std=c++14 -Wall -Wextra" )
|
||||||
|
|
||||||
include_directories (include)
|
add_library(${PROJECT_NAME} INTERFACE)
|
||||||
|
target_compile_options(${PROJECT_NAME} INTERFACE -Wall -Wextra)
|
||||||
|
# variable_templates ensures c++14 standard or greater
|
||||||
|
target_compile_features(${PROJECT_NAME} INTERFACE cxx_variable_templates)
|
||||||
|
|
||||||
|
target_include_directories(${PROJECT_NAME} INTERFACE include)
|
||||||
|
|
||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
target_include_directories(${PROJECT_NAME} INTERFACE ${OPENSSL_INCLUDE_DIR})
|
||||||
|
target_link_libraries(${PROJECT_NAME} INTERFACE ${OPENSSL_LIBRARIES})
|
||||||
|
|
||||||
find_package(GTest REQUIRED)
|
find_package(GTest REQUIRED)
|
||||||
include_directories(${GTEST_INCLUDE_DIRS})
|
target_include_directories(${PROJECT_NAME} INTERFACE ${GTEST_INCLUDE_DIRS})
|
||||||
|
target_link_libraries(${PROJECT_NAME} INTERFACE ${GTEST_LIBRARIES})
|
||||||
|
|
||||||
enable_testing()
|
# Only if not a subproject
|
||||||
|
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
enable_testing()
|
||||||
|
|
||||||
# Recurse into the "Hello" and "Demo" subdirectories. This does not actually
|
# Recurse into the "Hello" and "Demo" subdirectories. This does not actually
|
||||||
# cause another cmake executable to run. The same process will walk through
|
# cause another cmake executable to run. The same process will walk through
|
||||||
# the project's entire directory structure.
|
# the project's entire directory structure.
|
||||||
add_subdirectory (tests)
|
add_subdirectory(tests)
|
||||||
|
add_subdirectory(examples)
|
||||||
add_subdirectory (examples)
|
endif()
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
|
|
||||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
|
||||||
|
|
||||||
SET(CERT_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/rsa_256")
|
SET(CERT_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/rsa_256")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCERT_ROOT_DIR=\"\\\"${CERT_ROOT_DIR}\\\"\"")
|
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCERT_ROOT_DIR=\"\\\"${CERT_ROOT_DIR}\\\"\"")
|
||||||
|
|
||||||
add_executable(simple_ex1 simple_ex1.cc)
|
add_executable(simple_ex1 simple_ex1.cc)
|
||||||
target_link_libraries(simple_ex1 ${OPENSSL_LIBRARIES} ${GTEST_LIBRARIES})
|
target_link_libraries(simple_ex1 cpp-jwt)
|
||||||
|
target_compile_definitions(simple_ex1 PRIVATE CERT_ROOT_DIR="${CERT_ROOT_DIR}")
|
||||||
add_test(NAME simple_ex1 COMMAND ./simple_ex1 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
add_test(NAME simple_ex1 COMMAND ./simple_ex1 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_executable(simple_ex2 simple_ex2.cc)
|
add_executable(simple_ex2 simple_ex2.cc)
|
||||||
target_link_libraries(simple_ex2 ${OPENSSL_LIBRARIES} ${GTEST_LIBRARIES})
|
target_link_libraries(simple_ex2 cpp-jwt)
|
||||||
|
target_compile_definitions(simple_ex2 PRIVATE CERT_ROOT_DIR="${CERT_ROOT_DIR}")
|
||||||
add_test(NAME simple_ex2 COMMAND ./simple_ex2 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
add_test(NAME simple_ex2 COMMAND ./simple_ex2 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_executable(simple_ex3_rsa simple_ex3_rsa.cc)
|
add_executable(simple_ex3_rsa simple_ex3_rsa.cc)
|
||||||
target_link_libraries(simple_ex3_rsa ${OPENSSL_LIBRARIES} ${GTEST_LIBRARIES})
|
target_link_libraries(simple_ex3_rsa cpp-jwt)
|
||||||
|
target_compile_definitions(simple_ex3_rsa PRIVATE CERT_ROOT_DIR="${CERT_ROOT_DIR}")
|
||||||
add_test(NAME simple_ex3_rsa COMMAND ./simple_ex3_rsa WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
add_test(NAME simple_ex3_rsa COMMAND ./simple_ex3_rsa WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
|
|
@ -1,33 +1,37 @@
|
||||||
|
|
||||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
|
||||||
|
|
||||||
SET(CERT_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/certs")
|
SET(CERT_ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/certs")
|
||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCERT_ROOT_DIR=\"\\\"${CERT_ROOT_DIR}\\\"\"")
|
# SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DCERT_ROOT_DIR=\"\"${CERT_ROOT_DIR}\"\"")
|
||||||
|
|
||||||
add_executable(test_jwt_object test_jwt_object.cc)
|
add_executable(test_jwt_object test_jwt_object.cc)
|
||||||
target_link_libraries(test_jwt_object ${OPENSSL_LIBRARIES} ${GTEST_LIBRARIES})
|
target_link_libraries(test_jwt_object cpp-jwt)
|
||||||
|
target_compile_definitions(test_jwt_object PRIVATE CERT_ROOT_DIR="${CERT_ROOT_DIR}")
|
||||||
add_test(NAME test_jwt_object COMMAND ./test_jwt_object WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
add_test(NAME test_jwt_object COMMAND ./test_jwt_object WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_executable(test_jwt_encode test_jwt_encode.cc)
|
add_executable(test_jwt_encode test_jwt_encode.cc)
|
||||||
target_link_libraries(test_jwt_encode ${OPENSSL_LIBRARIES} ${GTEST_LIBRARIES})
|
target_link_libraries(test_jwt_encode cpp-jwt)
|
||||||
|
target_compile_definitions(test_jwt_encode PRIVATE CERT_ROOT_DIR="${CERT_ROOT_DIR}")
|
||||||
add_test(NAME test_jwt_encode COMMAND ./test_jwt_encode WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
add_test(NAME test_jwt_encode COMMAND ./test_jwt_encode WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_executable(test_jwt_decode test_jwt_decode.cc)
|
add_executable(test_jwt_decode test_jwt_decode.cc)
|
||||||
target_link_libraries(test_jwt_decode ${OPENSSL_LIBRARIES} ${GTEST_LIBRARIES})
|
target_link_libraries(test_jwt_decode cpp-jwt)
|
||||||
|
target_compile_definitions(test_jwt_decode PRIVATE CERT_ROOT_DIR="${CERT_ROOT_DIR}")
|
||||||
add_test(NAME test_jwt_decode COMMAND ./test_jwt_decode WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
add_test(NAME test_jwt_decode COMMAND ./test_jwt_decode WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_executable(test_jwt_decode_verifiy test_jwt_decode_verifiy.cc)
|
add_executable(test_jwt_decode_verifiy test_jwt_decode_verifiy.cc)
|
||||||
target_link_libraries(test_jwt_decode_verifiy ${OPENSSL_LIBRARIES} ${GTEST_LIBRARIES})
|
target_link_libraries(test_jwt_decode_verifiy cpp-jwt)
|
||||||
|
target_compile_definitions(test_jwt_decode_verifiy PRIVATE CERT_ROOT_DIR="${CERT_ROOT_DIR}")
|
||||||
add_test(NAME test_jwt_decode_verifiy COMMAND ./test_jwt_decode_verifiy WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
add_test(NAME test_jwt_decode_verifiy COMMAND ./test_jwt_decode_verifiy WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_executable(test_jwt_decode_verifiy_with_exception test_jwt_decode_verifiy_with_exception.cc)
|
add_executable(test_jwt_decode_verifiy_with_exception test_jwt_decode_verifiy_with_exception.cc)
|
||||||
target_link_libraries(test_jwt_decode_verifiy_with_exception ${OPENSSL_LIBRARIES} ${GTEST_LIBRARIES})
|
target_link_libraries(test_jwt_decode_verifiy_with_exception cpp-jwt)
|
||||||
|
target_compile_definitions(test_jwt_decode_verifiy_with_exception PRIVATE CERT_ROOT_DIR="${CERT_ROOT_DIR}")
|
||||||
add_test(NAME test_jwt_decode_verifiy_with_exception COMMAND ./test_jwt_decode_verifiy_with_exception WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
add_test(NAME test_jwt_decode_verifiy_with_exception COMMAND ./test_jwt_decode_verifiy_with_exception WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_executable(test_jwt_rsa test_jwt_rsa.cc)
|
add_executable(test_jwt_rsa test_jwt_rsa.cc)
|
||||||
target_link_libraries(test_jwt_rsa ${OPENSSL_LIBRARIES} ${GTEST_LIBRARIES} )
|
target_link_libraries(test_jwt_rsa cpp-jwt)
|
||||||
|
target_compile_definitions(test_jwt_rsa PRIVATE CERT_ROOT_DIR="${CERT_ROOT_DIR}")
|
||||||
add_test(NAME test_jwt_rsa COMMAND ./test_jwt_rsa WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
add_test(NAME test_jwt_rsa COMMAND ./test_jwt_rsa WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
add_executable(test_jwt_es test_jwt_es.cc)
|
add_executable(test_jwt_es test_jwt_es.cc)
|
||||||
target_link_libraries(test_jwt_es ${OPENSSL_LIBRARIES} ${GTEST_LIBRARIES})
|
target_link_libraries(test_jwt_es cpp-jwt)
|
||||||
|
target_compile_definitions(test_jwt_es PRIVATE CERT_ROOT_DIR="${CERT_ROOT_DIR}")
|
||||||
add_test(NAME test_jwt_es COMMAND ./test_jwt_es WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
add_test(NAME test_jwt_es COMMAND ./test_jwt_es WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue