mirror of
https://github.com/jbeder/yaml-cpp.git
synced 2025-09-08 12:21:17 +00:00
Add test and util sources to make format
This commit is contained in:
@@ -54,6 +54,29 @@ option(MSVC_STHREADED_RT "MSVC: Build with single-threaded static runtime libs (
|
||||
###
|
||||
### Sources, headers, directories and libs
|
||||
###
|
||||
|
||||
# From http://www.cmake.org/pipermail/cmake/2010-March/035992.html:
|
||||
# function to collect all the sources from sub-directories
|
||||
# into a single list
|
||||
function(add_sources)
|
||||
get_property(is_defined GLOBAL PROPERTY SRCS_LIST DEFINED)
|
||||
if(NOT is_defined)
|
||||
define_property(GLOBAL PROPERTY SRCS_LIST
|
||||
BRIEF_DOCS "List of source files"
|
||||
FULL_DOCS "List of all source files in the entire project")
|
||||
endif()
|
||||
# make absolute paths
|
||||
set(SRCS)
|
||||
foreach(s IN LISTS ARGN)
|
||||
if(NOT IS_ABSOLUTE "${s}")
|
||||
get_filename_component(s "${s}" ABSOLUTE)
|
||||
endif()
|
||||
list(APPEND SRCS "${s}")
|
||||
endforeach()
|
||||
# append to global list
|
||||
set_property(GLOBAL APPEND PROPERTY SRCS_LIST "${SRCS}")
|
||||
endfunction(add_sources)
|
||||
|
||||
set(header_directory "include/yaml-cpp/")
|
||||
|
||||
file(GLOB sources "src/[a-zA-Z]*.cpp")
|
||||
@@ -68,7 +91,7 @@ else()
|
||||
add_definitions(-DYAML_CPP_NO_CONTRIB)
|
||||
endif()
|
||||
|
||||
set(all_sources
|
||||
set(library_sources
|
||||
${sources}
|
||||
${public_headers}
|
||||
${private_headers}
|
||||
@@ -76,6 +99,7 @@ set(all_sources
|
||||
${contrib_public_headers}
|
||||
${contrib_private_headers}
|
||||
)
|
||||
add_sources(${library_sources})
|
||||
|
||||
if(VERBOSE)
|
||||
message(STATUS "sources: ${sources}")
|
||||
@@ -162,10 +186,6 @@ if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR
|
||||
COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR}
|
||||
COMMENT "Adjusting settings for release compilation"
|
||||
VERBATIM)
|
||||
add_custom_target(format
|
||||
COMMAND clang-format --style=file -i ${all_sources}
|
||||
COMMENT "Running clang-format"
|
||||
VERBATIM)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -246,7 +266,7 @@ set(_INSTALL_DESTINATIONS
|
||||
###
|
||||
### Library
|
||||
###
|
||||
add_library(yaml-cpp ${all_sources})
|
||||
add_library(yaml-cpp ${library_sources})
|
||||
set_target_properties(yaml-cpp PROPERTIES
|
||||
COMPILE_FLAGS "${yaml_c_flags} ${yaml_cxx_flags}"
|
||||
)
|
||||
@@ -296,3 +316,13 @@ if(YAML_CPP_BUILD_TOOLS)
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(util)
|
||||
endif()
|
||||
|
||||
### Formatting
|
||||
if(${CMAKE_BUILD_TOOL} MATCHES make OR ${CMAKE_BUILD_TOOL} MATCHES gmake)
|
||||
get_property(all_sources GLOBAL PROPERTY SRCS_LIST)
|
||||
message(STATUS ${all_sources})
|
||||
add_custom_target(format
|
||||
COMMAND clang-format --style=file -i ${all_sources}
|
||||
COMMENT "Running clang-format"
|
||||
VERBATIM)
|
||||
endif()
|
@@ -18,6 +18,7 @@ file(GLOB test_sources [a-z_]*.cpp integration/[a-z_]*.cpp)
|
||||
file(GLOB test_core_sources core/[a-z]*.cpp)
|
||||
|
||||
list(APPEND test_sources ${test_core_sources})
|
||||
add_sources(${test_sources} ${test_headers})
|
||||
|
||||
include_directories(${YAML_CPP_SOURCE_DIR}/test)
|
||||
|
||||
|
@@ -1,5 +1,7 @@
|
||||
add_sources(sandbox.cpp)
|
||||
add_executable(sandbox sandbox.cpp)
|
||||
target_link_libraries(sandbox yaml-cpp)
|
||||
|
||||
add_sources(read.cpp)
|
||||
add_executable(read read.cpp)
|
||||
target_link_libraries(read yaml-cpp)
|
||||
|
Reference in New Issue
Block a user