first
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
cmake_minimum_required(VERSION 3.5...3.30)
|
||||
project(yaml-cpp-consumer LANGUAGES CXX)
|
||||
|
||||
find_package(yaml-cpp CONFIG REQUIRED)
|
||||
get_target_property(LIBRARY_TYPE yaml-cpp::yaml-cpp TYPE)
|
||||
|
||||
if(LIBRARY_TYPE STREQUAL "SHARED_LIBRARY")
|
||||
if(NOT YAML_CPP_SHARED_LIBS_BUILT)
|
||||
message(FATAL_ERROR "Library type (${LIBRARY_TYPE}) contradicts config: ${YAML_CPP_SHARED_LIBS_BUILT}")
|
||||
endif()
|
||||
else()
|
||||
if(YAML_CPP_SHARED_LIBS_BUILT)
|
||||
message(FATAL_ERROR "Library type (${LIBRARY_TYPE}) contradicts config: ${YAML_CPP_SHARED_LIBS_BUILT}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_executable(main main.cpp)
|
||||
if (NOT DEFINED CMAKE_CXX_STANDARD)
|
||||
set_target_properties(main PROPERTIES CXX_STANDARD 11)
|
||||
endif()
|
||||
if(MSVC)
|
||||
if(YAML_CPP_SHARED_LIBS_BUILT)
|
||||
set_property(TARGET main PROPERTY MSVC_RUNTIME_LIBRARY
|
||||
MultiThreaded$<$<CONFIG:Debug>:Debug>DLL)
|
||||
else()
|
||||
set_property(TARGET main PROPERTY MSVC_RUNTIME_LIBRARY
|
||||
MultiThreaded$<$<CONFIG:Debug>:Debug>)
|
||||
endif()
|
||||
endif()
|
||||
target_link_libraries(main PRIVATE ${YAML_CPP_LIBRARIES})
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "yaml-cpp/yaml.h"
|
||||
|
||||
int main(int, char**) { YAML::Parser foo{}; }
|
||||
@@ -0,0 +1,17 @@
|
||||
if(NOT DEFINED YAML_CPP_PC_FILE)
|
||||
message(FATAL_ERROR "YAML_CPP_PC_FILE is required")
|
||||
endif()
|
||||
|
||||
file(READ "${YAML_CPP_PC_FILE}" yaml_cpp_pc)
|
||||
set(static_define "Cflags.private: -DYAML_CPP_STATIC_DEFINE")
|
||||
string(FIND "${yaml_cpp_pc}" "${static_define}" static_define_pos)
|
||||
|
||||
if(YAML_BUILD_SHARED_LIBS)
|
||||
if(NOT static_define_pos EQUAL -1)
|
||||
message(FATAL_ERROR
|
||||
"Shared-library pkg-config metadata contains ${static_define}")
|
||||
endif()
|
||||
elseif(static_define_pos EQUAL -1)
|
||||
message(FATAL_ERROR
|
||||
"Static-library pkg-config metadata does not contain ${static_define}")
|
||||
endif()
|
||||
@@ -0,0 +1,21 @@
|
||||
include("${YAML_CPP_SOURCE_DIR}/cmake/yaml-cpp-sources.cmake")
|
||||
|
||||
file(GLOB actual_sources
|
||||
LIST_DIRECTORIES false
|
||||
RELATIVE "${YAML_CPP_SOURCE_DIR}"
|
||||
"${YAML_CPP_SOURCE_DIR}/src/*.cpp"
|
||||
"${YAML_CPP_SOURCE_DIR}/src/contrib/*.cpp")
|
||||
|
||||
set(expected_sources
|
||||
${yaml-cpp-contrib-sources}
|
||||
${yaml-cpp-sources})
|
||||
|
||||
list(SORT actual_sources)
|
||||
list(SORT expected_sources)
|
||||
|
||||
if(NOT "${actual_sources}" STREQUAL "${expected_sources}")
|
||||
message(FATAL_ERROR
|
||||
"yaml-cpp source list is out of date.\n"
|
||||
"Expected: ${expected_sources}\n"
|
||||
"Actual: ${actual_sources}")
|
||||
endif()
|
||||
Reference in New Issue
Block a user