2017-06-29 04:21:01 +08:00
|
|
|
cmake_minimum_required(VERSION 3.5.1)
|
|
|
|
project(libconfig C CXX)
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
add_compile_options(/W3 /wd4005 /wd4996 /wd4018 -D_CRT_SECURE_NO_WARNINGS)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(C_SOURCES
|
2017-06-30 04:38:45 +08:00
|
|
|
lib/grammar.c
|
|
|
|
lib/libconfig.c
|
|
|
|
lib/scanctx.c
|
|
|
|
lib/scanner.c
|
|
|
|
lib/strbuf.c
|
2017-12-26 12:43:00 +08:00
|
|
|
lib/strvec.c
|
|
|
|
lib/util.c
|
|
|
|
lib/wincompat.c
|
2017-06-29 04:21:01 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
set(CPP_SOURCES
|
2017-06-30 04:38:45 +08:00
|
|
|
lib/libconfigcpp.cc
|
2017-06-29 04:21:01 +08:00
|
|
|
)
|
|
|
|
|
2017-06-30 06:18:58 +08:00
|
|
|
find_path(STDINT_H stdint.h)
|
|
|
|
|
2017-12-26 12:43:00 +08:00
|
|
|
include_directories(lib ${STDINT_H})
|
2017-07-08 14:11:46 +08:00
|
|
|
|
|
|
|
add_definitions(-DYY_NO_UNISTD_H -DYY_USE_CONST)
|
2017-06-29 04:21:01 +08:00
|
|
|
|
2017-06-30 04:38:45 +08:00
|
|
|
add_library(libconfig ${C_SOURCES})
|
2017-07-04 12:27:49 +08:00
|
|
|
add_library(libconfig++ ${CPP_SOURCES})
|
|
|
|
|
2017-06-30 04:38:45 +08:00
|
|
|
if(BUILD_SHARED_LIBS)
|
2017-07-08 14:11:46 +08:00
|
|
|
target_compile_definitions(libconfig PRIVATE -DLIBCONFIG_EXPORTS)
|
|
|
|
target_compile_definitions(libconfig++ PRIVATE -DLIBCONFIGXX_EXPORTS)
|
2017-06-29 04:21:01 +08:00
|
|
|
else()
|
2017-07-08 14:11:46 +08:00
|
|
|
target_compile_definitions(libconfig PUBLIC -DLIBCONFIG_STATIC)
|
|
|
|
target_compile_definitions(libconfig++ PUBLIC -DLIBCONFIGXX_STATIC)
|
2017-06-29 04:21:01 +08:00
|
|
|
endif()
|
|
|
|
|
2021-01-20 07:29:30 +08:00
|
|
|
if (WIN32)
|
|
|
|
# Linux doesn't have shlwapi
|
|
|
|
target_link_libraries(libconfig shlwapi)
|
|
|
|
endif()
|
2017-07-08 14:11:46 +08:00
|
|
|
target_link_libraries(libconfig++ PRIVATE libconfig)
|
|
|
|
|
2017-06-29 04:21:01 +08:00
|
|
|
install(
|
|
|
|
TARGETS libconfig libconfig++
|
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
)
|
|
|
|
|
|
|
|
if(NOT DISABLE_INSTALL_HEADERS)
|
2017-07-08 14:11:46 +08:00
|
|
|
install(FILES lib/libconfig.h++ lib/libconfig.h DESTINATION include)
|
2017-06-29 04:21:01 +08:00
|
|
|
endif()
|