1 Star 2 Fork 0

SHADOW/libtoml

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CMakeLists.txt 3.13 KB
一键复制 编辑 原始数据 按行查看 历史
cmake_minimum_required(VERSION 3.13)
project(LIBTOML VERSION 0.0.1 LANGUAGES C CXX)
# This project can use C11, but will gracefully decay down to C89.
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED OFF)
set(CMAKE_C_EXTENSIONS OFF)
# This project requires C++11.
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(LIBTOML_BUILD_TESTS "Build libtoml's unit tests" ON)
option(LIBTOML_BUILD_EXAMPLE "Build libtoml's example" ON)
aux_source_directory(${PROJECT_SOURCE_DIR}/src TOML_IMPL_SRC)
add_library(toml STATIC "")
target_sources(toml
PRIVATE
${TOML_IMPL_SRC}
)
target_include_directories(toml
PRIVATE
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}
)
target_compile_options(toml
PRIVATE
-Wall
)
# unit test
if(LIBTOML_BUILD_TESTS)
# using google test source library
add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/googletest-1.10.0 googletest)
enable_testing()
function(libtoml_unit_test test_file)
get_filename_component(test_target_name "${test_file}" NAME_WE)
add_executable("${test_target_name}" "")
target_sources("${test_target_name}"
PRIVATE
"${test_file}"
)
target_include_directories("${test_target_name}"
PRIVATE
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/third_party/googletest-1.10.0/googletest/include
)
target_compile_options("${test_target_name}"
PRIVATE
-fno-access-control
-Wall
)
target_link_libraries("${test_target_name}"
PRIVATE
toml
gtest
)
target_compile_definitions("${test_target_name}"
PRIVATE
TEST_CASE_DIR="${PROJECT_SOURCE_DIR}/etc"
)
add_test(NAME "${test_target_name}" COMMAND "${test_target_name}" "${PROJECT_SOURCE_DIR}")
endfunction(libtoml_unit_test)
libtoml_unit_test("${PROJECT_SOURCE_DIR}/test/array_of_table_test.cc")
libtoml_unit_test("${PROJECT_SOURCE_DIR}/test/array_test.cc")
libtoml_unit_test("${PROJECT_SOURCE_DIR}/test/boolean_test.cc")
libtoml_unit_test("${PROJECT_SOURCE_DIR}/test/comment_test.cc")
libtoml_unit_test("${PROJECT_SOURCE_DIR}/test/datetime_test.cc")
libtoml_unit_test("${PROJECT_SOURCE_DIR}/test/float_test.cc")
libtoml_unit_test("${PROJECT_SOURCE_DIR}/test/inline_array_test.cc")
libtoml_unit_test("${PROJECT_SOURCE_DIR}/test/inline_table_test.cc")
libtoml_unit_test("${PROJECT_SOURCE_DIR}/test/integer_test.cc")
libtoml_unit_test("${PROJECT_SOURCE_DIR}/test/keys_test.cc")
libtoml_unit_test("${PROJECT_SOURCE_DIR}/test/kvpair_test.cc")
libtoml_unit_test("${PROJECT_SOURCE_DIR}/test/string_test.cc")
libtoml_unit_test("${PROJECT_SOURCE_DIR}/test/table_test.cc")
endif(LIBTOML_BUILD_TESTS)
if(LIBTOML_BUILD_EXAMPLE)
add_executable(sample "")
target_sources(sample
PRIVATE
"${PROJECT_SOURCE_DIR}/example/sample.cc"
)
target_include_directories(sample
PRIVATE
${PROJECT_SOURCE_DIR}/include
)
target_compile_options(sample
PRIVATE
-Wall
)
target_link_libraries(sample
PRIVATE
toml
)
endif(LIBTOML_BUILD_EXAMPLE)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/shadowyuan/libtoml.git
[email protected]:shadowyuan/libtoml.git
shadowyuan
libtoml
libtoml
master

搜索帮助