Skip to content

Commit

Permalink
Ability to disable JinjaCpp installation rules (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov authored May 24, 2024
1 parent a853f8e commit 9ae7e1f
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 149 deletions.
94 changes: 51 additions & 43 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
cmake_minimum_required(VERSION 3.23.0)

if(POLICY CMP0135)
cmake_policy(SET CMP0135 NEW)
endif()

project(Jinja2Cpp VERSION 1.3.1)

if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
Expand All @@ -23,6 +28,7 @@ option(JINJA2CPP_STRICT_WARNINGS "Enable additional warnings and treat them as e
option(JINJA2CPP_BUILD_SHARED "Build shared linkage version of Jinja2Cpp" OFF)
option(JINJA2CPP_PIC "Control -fPIC option for library build" OFF)
option(JINJA2CPP_VERBOSE "Add extra debug output to the build scripts" OFF)
option(JINJA2CPP_INSTALL "Add installation rules for JinjaCpp targets" ${JINJA2CPP_IS_MAIN_PROJECT})

if (DEFINED BUILD_SHARED_LIBS)
set(JINJA2CPP_BUILD_SHARED ${BUILD_SHARED_LIBS})
Expand Down Expand Up @@ -298,51 +304,53 @@ Jinja2CppGetTargetIncludeDir(STRING-VIEW-LITE nonstd::string-view-lite)
# We can't use EXPORT feature of 'install' as is due to limitation of subproject's targets installation
# So jinja2cpp-config.cmake should be written manually

install(
TARGETS
${LIB_TARGET_NAME}
EXPORT
InstallTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
FILE_SET HEADERS
)
if(JINJA2CPP_INSTALL)
install(
TARGETS
${LIB_TARGET_NAME}
EXPORT
InstallTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
FILE_SET HEADERS
)

install(
FILES
${CMAKE_BINARY_DIR}/jinja2cpp.pc
DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig
)
install(
FILES
${CMAKE_BINARY_DIR}/jinja2cpp.pc
DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig
)

install(
EXPORT
InstallTargets
FILE
jinja2cpp-cfg.cmake
DESTINATION
${JINJA2CPP_INSTALL_CONFIG_DIR}
)
install(
EXPORT
InstallTargets
FILE
jinja2cpp-cfg.cmake
DESTINATION
${JINJA2CPP_INSTALL_CONFIG_DIR}
)

configure_package_config_file(
cmake/public/jinja2cpp-config.cmake.in
${JINJA2CPP_TMP_CONFIG_PATH}/jinja2cpp-config.cmake
INSTALL_DESTINATION ${JINJA2CPP_TMP_CONFIG_PATH}
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
configure_package_config_file(
cmake/public/jinja2cpp-config.cmake.in
${JINJA2CPP_TMP_CONFIG_PATH}/jinja2cpp-config.cmake
INSTALL_DESTINATION ${JINJA2CPP_TMP_CONFIG_PATH}
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)

configure_package_config_file(
cmake/public/jinja2cpp-config-deps-${JINJA2CPP_DEPS_MODE}.cmake.in
${JINJA2CPP_TMP_CONFIG_PATH}/jinja2cpp-config-deps.cmake
INSTALL_DESTINATION ${JINJA2CPP_TMP_CONFIG_PATH}
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
configure_package_config_file(
cmake/public/jinja2cpp-config-deps-${JINJA2CPP_DEPS_MODE}.cmake.in
${JINJA2CPP_TMP_CONFIG_PATH}/jinja2cpp-config-deps.cmake
INSTALL_DESTINATION ${JINJA2CPP_TMP_CONFIG_PATH}
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)

install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${JINJA2CPP_TMP_CONFIG_PATH}/${LIB_TARGET_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${JINJA2CPP_TMP_CONFIG_PATH}/${LIB_TARGET_NAME}-config-deps.cmake
DESTINATION
${JINJA2CPP_INSTALL_CONFIG_DIR}
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${JINJA2CPP_TMP_CONFIG_PATH}/${LIB_TARGET_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${JINJA2CPP_TMP_CONFIG_PATH}/${LIB_TARGET_NAME}-config-deps.cmake
DESTINATION
${JINJA2CPP_INSTALL_CONFIG_DIR}
)
endif()
14 changes: 8 additions & 6 deletions cmake/coverage.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ function(add_coverage_target _TARGET)
)
target_link_libraries(${_TARGET} INTERFACE gcov)

install(
TARGETS
${_TARGET}
EXPORT
InstallTargets
)
if(JINJA2CPP_INSTALL)
install(
TARGETS
${_TARGET}
EXPORT
InstallTargets
)
endif()
endfunction()
25 changes: 0 additions & 25 deletions cmake/patches/0001-fix-skip-install-rules.patch

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/public/jinja2cpp-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ if (JINJA2CPP_BUILD_SHARED)
endif()


# INTERFACE_LINK_LIBRARIES "nonstd::expected-lite;nonstd::variant-lite;nonstd::value_ptr-lite;nonstd::optional-lite;\$<LINK_ONLY:boost::variant>;\$<LINK_ONLY:boost::filesystem>;\$<LINK_ONLY:boost::algorithm>"
# INTERFACE_LINK_LIBRARIES "nonstd::expected-lite;nonstd::variant-lite;nonstd::value_ptr-lite;nonstd::optional-lite;\$<LINK_ONLY:boost::variant>;\$<LINK_ONLY:boost::filesystem>;\$<LINK_ONLY:boost::numeric_conversion>;\$<LINK_ONLY:boost::algorithm>"

if(CMAKE_VERSION VERSION_LESS 2.8.12)
message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.")
Expand Down
14 changes: 8 additions & 6 deletions cmake/sanitizer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ function(add_sanitizer_target _TARGET)
${_BASE_ENABLE_SANITIZER_FLAGS}
)

install(
TARGETS
${_TARGET}
EXPORT
InstallTargets
)
if(JINJA2CPP_INSTALL)
install(
TARGETS
${_TARGET}
EXPORT
InstallTargets
)
endif()
endfunction()


2 changes: 1 addition & 1 deletion conanfile.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[requires]
boost/1.83.0
boost/1.85.0
expected-lite/0.6.3
fmt/10.1.1
nlohmann_json/3.11.2
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ endif()
if (NOT DEFINED JINJA2_PRIVATE_LIBS_INT)
set(JINJA2CPP_PRIVATE_LIBS ${JINJA2CPP_PRIVATE_LIBS}
Boost::variant Boost::filesystem Boost::algorithm Boost::lexical_cast Boost::json
Boost::regex fmt RapidJson)
Boost::regex Boost::numeric_conversion fmt RapidJson)
else ()
set (JINJA2CPP_PRIVATE_LIBS ${JINJA2_PRIVATE_LIBS_INT})
endif ()
Expand Down
61 changes: 34 additions & 27 deletions thirdparty/external_boost_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,52 @@ if (MSVC)
endif ()
endif ()

find_package(boost_algorithm ${FIND_BOOST_PACKAGE_QUIET})
find_package(boost_filesystem ${FIND_BOOST_PACKAGE_QUIET})
find_package(boost_json ${FIND_BOOST_PACKAGE_QUIET})
find_package(boost_optional ${FIND_BOOST_PACKAGE_QUIET})
find_package(boost_variant ${FIND_BOOST_PACKAGE_QUIET})
find_package(boost_regex ${FIND_BOOST_PACKAGE_QUIET})
find_package(boost_algorithm ${FIND_BOOST_PACKAGE_QUIET})
find_package(boost_filesystem ${FIND_BOOST_PACKAGE_QUIET})
find_package(boost_numeric_conversion ${FIND_BOOST_PACKAGE_QUIET})
find_package(boost_json ${FIND_BOOST_PACKAGE_QUIET})
find_package(boost_optional ${FIND_BOOST_PACKAGE_QUIET})
find_package(boost_variant ${FIND_BOOST_PACKAGE_QUIET})
find_package(boost_regex ${FIND_BOOST_PACKAGE_QUIET})

if (boost_algorithm_FOUND AND
boost_filesystem_FOUND AND
boost_numeric_conversion_FOUND AND
boost_json_FOUND AND
boost_optional_FOUND AND
boost_variant_FOUND AND boost_regex_FOUND)
imported_target_alias(boost_algorithm ALIAS boost_algorithm::boost_algorithm)
imported_target_alias(boost_filesystem ALIAS boost_filesystem::boost_filesystem)
imported_target_alias(boost_json ALIAS boost_json::boost_json)
imported_target_alias(boost_optional ALIAS boost_optional::boost_optional)
imported_target_alias(boost_variant ALIAS boost_variant::boost_variant)
imported_target_alias(boost_regex ALIAS boost_regex::boost_regex)
imported_target_alias(boost_algorithm ALIAS boost_algorithm::boost_algorithm)
imported_target_alias(boost_filesystem ALIAS boost_filesystem::boost_filesystem)
imported_target_alias(boost_numeric_conversion ALIAS numeric_conversion::numeric_conversion)
imported_target_alias(boost_json ALIAS boost_json::boost_json)
imported_target_alias(boost_optional ALIAS boost_optional::boost_optional)
imported_target_alias(boost_variant ALIAS boost_variant::boost_variant)
imported_target_alias(boost_regex ALIAS boost_regex::boost_regex)
else ()
find_package(Boost COMPONENTS system filesystem json regex ${FIND_BOOST_PACKAGE_QUIET} REQUIRED)
find_package(Boost COMPONENTS system filesystem numeric_conversion json regex ${FIND_BOOST_PACKAGE_QUIET} REQUIRED)

if (Boost_FOUND)
imported_target_alias(boost_algorithm ALIAS Boost::boost)
imported_target_alias(boost_filesystem ALIAS Boost::filesystem)
imported_target_alias(boost_json ALIAS Boost::json)
imported_target_alias(boost_optional ALIAS Boost::boost)
imported_target_alias(boost_variant ALIAS Boost::boost)
imported_target_alias(boost_regex ALIAS Boost::regex)
imported_target_alias(boost_algorithm ALIAS Boost::boost)
imported_target_alias(boost_filesystem ALIAS Boost::filesystem)
imported_target_alias(boost_numeric_conversion ALIAS Boost::numeric_conversion)
imported_target_alias(boost_json ALIAS Boost::json)
imported_target_alias(boost_optional ALIAS Boost::boost)
imported_target_alias(boost_variant ALIAS Boost::boost)
imported_target_alias(boost_regex ALIAS Boost::regex)
endif ()
endif ()

set(_additional_boost_install_targets)
if ("${JINJA2CPP_USE_REGEX}" STREQUAL "boost")
set(_additional_boost_install_targets "boost_regex")
set(_additional_boost_install_targets "boost_regex")
endif()

if(JINJA2CPP_INSTALL)
install(TARGETS boost_algorithm boost_filesystem boost_numeric_conversion boost_json boost_optional boost_variant ${_additional_boost_install_targets}
EXPORT InstallTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/boost
)
endif()
install(TARGETS boost_algorithm boost_filesystem boost_json boost_optional boost_variant ${_additional_boost_install_targets}
EXPORT InstallTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/static
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/boost
)
28 changes: 14 additions & 14 deletions thirdparty/internal_deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@ include(FetchContent)

FetchContent_Declare(
expected-lite
GIT_REPOSITORY https://github.com/martinmoene/expected-lite.git
GIT_TAG master
URL https://github.com/martinmoene/expected-lite/archive/3634b0a6d8dffcffad4d1355253d79290c0c754c.tar.gz
URL_HASH SHA256=ce3bf45480d3ef5f78aa3c06cc5ddea43f5e6b864d92571b6b9838a516e1848b
)
FetchContent_MakeAvailable(expected-lite)

FetchContent_Declare(
variant-lite
GIT_REPOSITORY https://github.com/martinmoene/variant-lite.git
GIT_TAG master
URL https://github.com/martinmoene/variant-lite/archive/5015e841cf143487f2d7e2f619b618d455658fab.tar.gz
URL_HASH SHA256=d343cfa347517a2ee318864f3e2a08af8e17e699de701c69c1cdbdab79d9331f
)
FetchContent_MakeAvailable(variant-lite)

FetchContent_Declare(
optional-lite
GIT_REPOSITORY https://github.com/martinmoene/optional-lite.git
GIT_TAG master
URL https://github.com/martinmoene/optional-lite/archive/2605a4b13094b0bf7a8ecdcde6d644370105bce5.tar.gz
URL_HASH SHA256=29d5ca8d24d1174bf3e933d2e5186f7d1dab3a4cfe7befbe0f0d2795e53e3e0d
)
FetchContent_MakeAvailable(optional-lite)

FetchContent_Declare(
string-view-lite
GIT_REPOSITORY https://github.com/martinmoene/string-view-lite.git
GIT_TAG master
URL https://github.com/martinmoene/string-view-lite/archive/6e5e519d69b4ea99c3095d85d8e1e3ff4d54bbaa.tar.gz
URL_HASH SHA256=fdcb41a43543f5970c617b4dd224b4c958316707cd61090f18e579072eb15b0e
)
FetchContent_MakeAvailable(string-view-lite)

set (FMT_INSTALL ON CACHE BOOL "" FORCE)
FetchContent_Declare(
fmt
GIT_REPOSITORY https://github.com/fmtlib/fmt.git
GIT_TAG 10.1.1
URL https://github.com/fmtlib/fmt/archive/refs/tags/10.2.1.tar.gz
URL_HASH SHA256=1250e4cc58bf06ee631567523f48848dc4596133e163f02615c97f78bab6c811
)
FetchContent_MakeAvailable(fmt)

Expand All @@ -44,8 +44,8 @@ set (RAPIDJSON_ENABLE_INSTRUMENTATION_OPT OFF CACHE BOOL "" FORCE)

FetchContent_Declare(
rapidjson
GIT_REPOSITORY https://github.com/Tencent/rapidjson.git
GIT_TAG 973dc9c06dcd3d035ebd039cfb9ea457721ec213
URL https://github.com/Tencent/rapidjson/archive/973dc9c06dcd3d035ebd039cfb9ea457721ec213.tar.gz
URL_HASH SHA256=d0c9e52823d493206eb721d38cb3a669ca0212360862bd15a3c2f7d35ea7c6f7
)
# GIT_TAG f9d53419e912910fd8fa57d5705fa41425428c35 - latest but broken revision
FetchContent_MakeAvailable(rapidjson)
Expand All @@ -63,8 +63,8 @@ if (JINJA2CPP_BUILD_TESTS)

FetchContent_Declare(
nlohmann_json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG develop
URL https://github.com/nlohmann/json/archive/8c391e04fe4195d8be862c97f38cfe10e2a3472e.tar.gz
URL_HASH SHA256=8ca375182e9557612f043eaa62dfc4224b41ddf07af704577666aadb7dd99a79
)
FetchContent_MakeAvailable(nlohmann_json)
endif()
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/thirdparty-conan-build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ find_package(optional-lite REQUIRED)
find_package(string-view-lite REQUIRED)
find_package(nlohmann_json REQUIRED)

find_package(Boost COMPONENTS algorithm filesystem json optional variant regex REQUIRED)
find_package(Boost COMPONENTS algorithm filesystem numeric_conversion json optional variant regex REQUIRED)
find_package(fmt REQUIRED)
find_package(RapidJSON REQUIRED)

set(JINJA2_PRIVATE_LIBS_INT Boost::headers Boost::filesystem)
set(JINJA2_PRIVATE_LIBS_INT Boost::headers Boost::filesystem Boost::numeric_conversion)
set(JINJA2_PUBLIC_LIBS_INT Boost::json fmt::fmt rapidjson Boost::regex
nlohmann_json::nlohmann_json nonstd::expected-lite nonstd::variant-lite nonstd::optional-lite nonstd::string-view-lite)
Loading

0 comments on commit 9ae7e1f

Please sign in to comment.