mirror of
https://github.com/pantor/inja.git
synced 2026-10-18 01:38:14 +00:00
Started to hunterize inja
This commit is contained in:
1 parent
e7179f99fe
commit
6dd2613783
4 files changed
+676
-21
No files matched your search
+44
-10
@@ -1,21 +1,55 @@
|
||||
##
|
||||
## Prepare "Catch" library for other executables
|
||||
##
|
||||
set(CATCH_INCLUDE_DIR "thirdparty/catch")
|
||||
add_library(Catch INTERFACE)
|
||||
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
##
|
||||
## HUNTER
|
||||
##
|
||||
option(HUNTER_ENABLED "Use hunter to manage dependencies" OFF)
|
||||
include("../cmake/HunterGate.cmake")
|
||||
HunterGate(
|
||||
URL "https://github.com/ruslo/hunter/archive/v0.19.156.tar.gz"
|
||||
SHA1 "8d5e4635b137365e0d1ade4d60accf4e2bb41f0d"
|
||||
)
|
||||
|
||||
##
|
||||
## PROJECT
|
||||
## name and version
|
||||
##
|
||||
project(inja-testing LANGUAGES CXX VERSION ${INJA_VERSION})
|
||||
|
||||
##
|
||||
## TARGETS
|
||||
##
|
||||
set(UNITTEST_TARGET_NAME "inja_unit")
|
||||
file(GLOB TEST_SOURCES "src/*.cpp")
|
||||
add_executable(${UNITTEST_TARGET_NAME} ${TEST_SOURCES})
|
||||
|
||||
target_link_libraries(${UNITTEST_TARGET_NAME} Catch)
|
||||
target_include_directories(${UNITTEST_TARGET_NAME} PRIVATE "../src" "thirdparty/json")
|
||||
##
|
||||
## INCLUDES
|
||||
##
|
||||
if(HUNTER_ENABLED) # Use Hunter to manage dependencies
|
||||
# Add Catch framework
|
||||
hunter_add_package(Catch)
|
||||
find_package(Catch CONFIG REQUIRED)
|
||||
# Add JSON package
|
||||
hunter_add_package(nlohmann_json)
|
||||
find_package(nlohmann_json CONFIG REQUIRED)
|
||||
# Add dependencies to target
|
||||
target_link_libraries(${UNITTEST_TARGET_NAME} Catch::Catch)
|
||||
target_link_libraries(${UNITTEST_TARGET_NAME} nlohmann_json)
|
||||
else() # Manage dependencies manually
|
||||
# Prepare "Catch" library for other executables
|
||||
set(CATCH_INCLUDE_DIR "thirdparty/catch")
|
||||
add_library(Catch INTERFACE)
|
||||
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})
|
||||
# Add dependencies to target
|
||||
target_link_libraries(${UNITTEST_TARGET_NAME} Catch)
|
||||
target_include_directories(${UNITTEST_TARGET_NAME} PRIVATE "../src" "thirdparty/json")
|
||||
endif()
|
||||
|
||||
##
|
||||
## Add tests to make
|
||||
##
|
||||
add_test(NAME "${UNITTEST_TARGET_NAME}_default"
|
||||
COMMAND ${UNITTEST_TARGET_NAME}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/build
|
||||
COMMAND ${UNITTEST_TARGET_NAME}
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/build
|
||||
)
|
||||
Reference in new issue
Block a user