-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* inja2 * header only * reduce dependencies * code cleaning * c++17 * use stdc++ * code cleaning * infrastructure * header only * add infrastructure * fix tests * use minimum clang 6 * code cleaning, polyfill for c++11 * fix some file tests * fix readme * update appveyor * fix polyfill and ci * fix polyfill * fix ci? * test msvc __cplusplus * add doxygen * activate all tests * code cleaning * add coveralls, set default to dot notation * add html test * add doxygen comments * test single_include file * change build folder in appveyor * correct make arguments in appveyor * fix appveyor arguments
- Loading branch information
Showing
77 changed files
with
7,417 additions
and
3,519 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,6 @@ dist | |
.coveralls.yml | ||
|
||
.vscode | ||
|
||
doc/html | ||
doc/latex |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,137 +1,69 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
|
||
## | ||
## PROJECT | ||
## | ||
project(inja LANGUAGES CXX VERSION 1.0.1) | ||
set(INJA_VERSION ${PROJECT_VERSION}) | ||
project(inja LANGUAGES CXX VERSION 2.0.0) | ||
|
||
|
||
## | ||
## OPTIONS | ||
## | ||
option(BUILD_UNIT_TESTS "Build the unit tests" ON) | ||
option(BUILD_BENCHMARK "Build the inja benchmark" OFF) | ||
option(HUNTER_ENABLED "Use hunter to manage dependencies" OFF) | ||
option(BUILD_TESTS "Build the inja unit tests" ON) | ||
option(BUILD_BENCHMARK "Build the inja benchmark" ON) | ||
option(COVERALLS "Generate coveralls data" OFF) | ||
|
||
|
||
## | ||
## HUNTER | ||
## | ||
if(HUNTER_ENABLED) | ||
include("cmake/HunterGate.cmake") | ||
HunterGate( | ||
URL "https://github.com/ruslo/hunter/archive/v0.19.156.tar.gz" | ||
SHA1 "8d5e4635b137365e0d1ade4d60accf4e2bb41f0d" | ||
) | ||
endif() | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") | ||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake) | ||
set(CMAKE_BUILD_TYPE Debug) | ||
# set(CMAKE_BUILD_TYPE Release) | ||
# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") | ||
|
||
|
||
## | ||
## CONFIGURATION | ||
## | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") | ||
set(INJA_INCLUDE_DIR include) | ||
set(INJA_SINGLE_INCLUDE_DIR single_include) | ||
set(INJA_HEADER_INSTALL_DIR include) | ||
add_library(inja INTERFACE) | ||
target_include_directories(inja INTERFACE include) | ||
|
||
|
||
execute_process(COMMAND python3 amalgamate/amalgamate.py -c amalgamate/config.json -s include WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) | ||
|
||
|
||
if (COVERALLS) | ||
include(Coveralls) | ||
coveralls_turn_on_coverage() | ||
|
||
if(WIN32 AND MSVC AND MSVC_VERSION LESS 1900) | ||
message(FATAL_ERROR "[${PROJECT_NAME}] Visual Studio versions prior to 2015 do not support the noexcept keyword, which is used in the JSON library.") | ||
file(GLOB_RECURSE COVERAGE_SRCS include/inja/*.hpp) | ||
|
||
# set(COVERAGE_SRCS test/unit.cpp test/unit-renderer.cpp include/inja) | ||
|
||
coveralls_setup("${COVERAGE_SRCS}" OFF) # If we should upload. | ||
endif() | ||
|
||
|
||
## | ||
## TESTS | ||
## create and configure the unit test target | ||
## | ||
if(BUILD_UNIT_TESTS) | ||
if(BUILD_TESTS) | ||
enable_testing() | ||
add_subdirectory(test) | ||
endif() | ||
|
||
add_executable(inja_test | ||
test/unit.cpp | ||
test/unit-files.cpp | ||
test/unit-renderer.cpp | ||
) | ||
target_link_libraries(inja_test PRIVATE inja) | ||
|
||
## | ||
## AMALGAMATE | ||
## amalgamate header files into single_include | ||
## | ||
execute_process(COMMAND python3 amalgamate/amalgamate.py -c amalgamate/config.json -s include | ||
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}) | ||
add_test(inja_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/inja_test) | ||
|
||
|
||
## | ||
## TARGETS | ||
## Build targets for the interface library | ||
## | ||
add_library(inja INTERFACE) | ||
target_include_directories(inja INTERFACE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${INJA_INCLUDE_DIR}> | ||
$<INSTALL_INTERFACE:${INJA_HEADER_INSTALL_DIR}> | ||
) | ||
|
||
|
||
add_library(inja_single INTERFACE) | ||
target_include_directories(inja_single INTERFACE | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${INJA_SINGLE_INCLUDE_DIR}> | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${INJA_INCLUDE_DIR}> | ||
$<INSTALL_INTERFACE:${INJA_HEADER_INSTALL_DIR}> | ||
) | ||
|
||
|
||
if(HUNTER_ENABLED) # Use Hunter to manage dependencies | ||
# Add JSON package | ||
hunter_add_package(nlohmann_json) | ||
find_package(nlohmann_json CONFIG REQUIRED) | ||
# Add dependencies to target | ||
target_link_libraries(inja INTERFACE nlohmann_json) | ||
add_library(single_inja INTERFACE) | ||
target_include_directories(single_inja INTERFACE single_include include) | ||
|
||
add_executable(single_inja_test | ||
test/unit.cpp | ||
test/unit-files.cpp | ||
test/unit-renderer.cpp | ||
) | ||
target_link_libraries(single_inja_test PRIVATE single_inja) | ||
|
||
add_test(single_inja_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/single_inja_test) | ||
endif() | ||
|
||
|
||
## | ||
## INSTALL | ||
## install header files, generate and install cmake config files for find_package() | ||
## | ||
set(include_install_dir ${INJA_HEADER_INSTALL_DIR}) | ||
set(config_install_dir "lib/cmake/${PROJECT_NAME}") | ||
set(generated_dir "${CMAKE_CURRENT_BINARY_DIR}/generated") | ||
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake") | ||
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake") | ||
set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets") | ||
set(namespace "${PROJECT_NAME}::") | ||
include(CMakePackageConfigHelpers) | ||
|
||
|
||
write_basic_package_version_file( | ||
"${version_config}" COMPATIBILITY SameMajorVersion | ||
) | ||
configure_package_config_file( | ||
"cmake/Config.cmake.in" | ||
"${project_config}" | ||
INSTALL_DESTINATION "${config_install_dir}" | ||
) | ||
|
||
install( | ||
TARGETS inja | ||
EXPORT "${TARGETS_EXPORT_NAME}" | ||
LIBRARY DESTINATION "lib" | ||
ARCHIVE DESTINATION "lib" | ||
RUNTIME DESTINATION "bin" | ||
INCLUDES DESTINATION "${include_install_dir}" | ||
) | ||
|
||
install( | ||
FILES ${INJA_INCLUDE_DIR}/inja.hpp | ||
DESTINATION "${include_install_dir}" | ||
) | ||
|
||
install( | ||
FILES "${project_config}" "${version_config}" | ||
DESTINATION "${config_install_dir}" | ||
) | ||
|
||
install( | ||
EXPORT "${TARGETS_EXPORT_NAME}" | ||
NAMESPACE "${namespace}" | ||
DESTINATION "${config_install_dir}" | ||
) | ||
if(BUILD_BENCHMARK) | ||
add_executable(inja_benchmark test/benchmark.cpp) | ||
target_link_libraries(inja_benchmark PRIVATE inja) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.