Allow building without CDL++ installed
This commit is contained in:
parent
2566265d1d
commit
c205f9fa94
4 changed files with 29 additions and 3 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -1,3 +1,6 @@
|
|||
[submodule "lib/cdlpp-db"]
|
||||
path = lib/cdlpp-db
|
||||
url = https://gitlab.com/niansa/cdlpp-db.git
|
||||
[submodule "lib/cdlpp"]
|
||||
path = lib/cdlpp
|
||||
url = https://gitlab.com/niansa/cdlpp.git
|
||||
|
|
|
@ -3,8 +3,10 @@ cmake_minimum_required(VERSION 3.5)
|
|||
project(tuxiflux LANGUAGES CXX)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(BUILD_SHARED_LIBS No)
|
||||
|
||||
include(embed.cmake)
|
||||
include(cdlpp.cmake)
|
||||
|
||||
add_compile_definitions(COMPILER_ID="${CMAKE_CXX_COMPILER_ID}")
|
||||
add_compile_definitions(COMPILER_VERSION="${CMAKE_CXX_COMPILER_VERSION}")
|
||||
|
@ -37,17 +39,18 @@ if (cpuid_FOUND)
|
|||
endif()
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(cdlpp REQUIRED IMPORTED_TARGET cdlpp)
|
||||
pkg_check_modules(fmt REQUIRED IMPORTED_TARGET fmt)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC
|
||||
PkgConfig::cdlpp PkgConfig::fmt cdlpp-db)
|
||||
PkgConfig::fmt cdlpp-db)
|
||||
|
||||
use_cdlpp(${PROJECT_NAME} lib/cdlpp)
|
||||
|
||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
option(ENABLE_EVAL "ENABLE_EVAL" ON)
|
||||
if (${ENABLE_EVAL})
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC
|
||||
-ldl)
|
||||
dl)
|
||||
add_compile_definitions(ENABLE_EVAL)
|
||||
endif()
|
||||
endif()
|
||||
|
|
19
cdlpp.cmake
Normal file
19
cdlpp.cmake
Normal file
|
@ -0,0 +1,19 @@
|
|||
function(use_cdlpp target cdlpp_src_dir)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
pkg_check_modules(cdlpp IMPORTED_TARGET cdlpp)
|
||||
|
||||
option(FORCE_SUBMODULE_CDLPP "Use CDLPP from submodule even if installed in system" No)
|
||||
if(cdlpp_FOUND OR FORCE_SUBMODULE_CDLPP)
|
||||
set(CDLPP_LIB PkgConfig::cdlpp)
|
||||
else()
|
||||
execute_process(
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
COMMAND git submodule update --init --recursive --depth 1
|
||||
)
|
||||
add_subdirectory(${cdlpp_src_dir})
|
||||
set(CDLPP_LIB "cdlpp")
|
||||
endif()
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PUBLIC
|
||||
${CDLPP_LIB})
|
||||
endfunction()
|
1
lib/cdlpp
Submodule
1
lib/cdlpp
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 50fb353a5ffe4c732810ab9bd1628be12b25eb54
|
Reference in a new issue