Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
yaml-cpp
Commits
dea3428c
Commit
dea3428c
authored
Mar 25, 2014
by
Jesse Beder
Browse files
Merge from core
parents
06635980
edf8ebe2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
69 additions
and
15 deletions
+69
-15
CMakeLists.txt
CMakeLists.txt
+55
-13
test/CMakeLists.txt
test/CMakeLists.txt
+11
-2
util/CMakeLists.txt
util/CMakeLists.txt
+3
-0
No files found.
CMakeLists.txt
View file @
dea3428c
...
@@ -54,6 +54,29 @@ option(MSVC_STHREADED_RT "MSVC: Build with single-threaded static runtime libs (
...
@@ -54,6 +54,29 @@ option(MSVC_STHREADED_RT "MSVC: Build with single-threaded static runtime libs (
###
###
### Sources, headers, directories and 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/"
)
set
(
header_directory
"include/yaml-cpp/"
)
file
(
GLOB sources
"src/[a-zA-Z]*.cpp"
)
file
(
GLOB sources
"src/[a-zA-Z]*.cpp"
)
...
@@ -68,6 +91,16 @@ else()
...
@@ -68,6 +91,16 @@ else()
add_definitions
(
-DYAML_CPP_NO_CONTRIB
)
add_definitions
(
-DYAML_CPP_NO_CONTRIB
)
endif
()
endif
()
set
(
library_sources
${
sources
}
${
public_headers
}
${
private_headers
}
${
contrib_sources
}
${
contrib_public_headers
}
${
contrib_private_headers
}
)
add_sources
(
${
library_sources
}
)
if
(
VERBOSE
)
if
(
VERBOSE
)
message
(
STATUS
"sources:
${
sources
}
"
)
message
(
STATUS
"sources:
${
sources
}
"
)
message
(
STATUS
"public_headers:
${
public_headers
}
"
)
message
(
STATUS
"public_headers:
${
public_headers
}
"
)
...
@@ -87,6 +120,9 @@ include_directories(${Boost_INCLUDE_DIRS})
...
@@ -87,6 +120,9 @@ include_directories(${Boost_INCLUDE_DIRS})
###
###
### General compilation settings
### General compilation settings
###
###
set
(
yaml_c_flags
${
CMAKE_C_FLAGS
}
)
set
(
yaml_cxx_flags
${
CMAKE_CXX_FLAGS
}
)
if
(
BUILD_SHARED_LIBS
)
if
(
BUILD_SHARED_LIBS
)
set
(
LABEL_SUFFIX
"shared"
)
set
(
LABEL_SUFFIX
"shared"
)
else
()
else
()
...
@@ -113,8 +149,9 @@ if(WIN32)
...
@@ -113,8 +149,9 @@ if(WIN32)
endif
()
endif
()
endif
()
endif
()
# GCC specialities
# GCC or Clang specialities
if
(
CMAKE_COMPILER_IS_GNUCXX
)
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
MATCHES
"GNU"
OR
"
${
CMAKE_CXX_COMPILER_ID
}
"
MATCHES
"Clang"
)
### General stuff
### General stuff
if
(
WIN32
)
if
(
WIN32
)
set
(
CMAKE_SHARED_LIBRARY_PREFIX
""
)
# DLLs do not have a "lib" prefix
set
(
CMAKE_SHARED_LIBRARY_PREFIX
""
)
# DLLs do not have a "lib" prefix
...
@@ -140,10 +177,10 @@ if(CMAKE_COMPILER_IS_GNUCXX)
...
@@ -140,10 +177,10 @@ if(CMAKE_COMPILER_IS_GNUCXX)
set
(
GCC_EXTRA_OPTIONS
"
${
GCC_EXTRA_OPTIONS
}
${
FLAG_TESTED
}
"
)
set
(
GCC_EXTRA_OPTIONS
"
${
GCC_EXTRA_OPTIONS
}
${
FLAG_TESTED
}
"
)
endif
()
endif
()
#
#
set
(
CMAKE_CXX_FLAGS
"-Wall
${
GCC_EXTRA_OPTIONS
}
-pedantic -Wno-long-long
${
CMAKE_CXX_FLAGS
}
"
)
set
(
yaml_cxx_flags
"-Wall
${
GCC_EXTRA_OPTIONS
}
-pedantic -Wno-long-long
${
yaml_cxx_flags
}
"
)
### Make specific
### Make specific
if
(
${
CMAKE_BUILD_TOOL
}
STREQUAL
make OR
${
CMAKE_BUILD_TOOL
}
STREQUAL
gmake
)
if
(
${
CMAKE_BUILD_TOOL
}
MATCHES
make OR
${
CMAKE_BUILD_TOOL
}
MATCHES
gmake
)
add_custom_target
(
debuggable $
(
MAKE
)
clean
add_custom_target
(
debuggable $
(
MAKE
)
clean
COMMAND
${
CMAKE_COMMAND
}
-DCMAKE_BUILD_TYPE=Debug
${
CMAKE_SOURCE_DIR
}
COMMAND
${
CMAKE_COMMAND
}
-DCMAKE_BUILD_TYPE=Debug
${
CMAKE_SOURCE_DIR
}
COMMENT
"Adjusting settings for debug compilation"
COMMENT
"Adjusting settings for debug compilation"
...
@@ -178,7 +215,7 @@ if(MSVC)
...
@@ -178,7 +215,7 @@ if(MSVC)
endif
()
endif
()
# correct linker options
# correct linker options
foreach
(
flag_var
CMAKE_C_FLAGS CMAKE_CXX_FLAGS
)
foreach
(
flag_var
yaml_c_flags yaml_cxx_flags
)
foreach
(
config_name
""
DEBUG RELEASE MINSIZEREL RELWITHDEBINFO
)
foreach
(
config_name
""
DEBUG RELEASE MINSIZEREL RELWITHDEBINFO
)
set
(
var_name
"
${
flag_var
}
"
)
set
(
var_name
"
${
flag_var
}
"
)
if
(
NOT
"
${
config_name
}
"
STREQUAL
""
)
if
(
NOT
"
${
config_name
}
"
STREQUAL
""
)
...
@@ -204,7 +241,7 @@ if(MSVC)
...
@@ -204,7 +241,7 @@ if(MSVC)
# /W3 = set warning level; see http://msdn.microsoft.com/en-us/library/thxezb7y.aspx
# /W3 = set warning level; see http://msdn.microsoft.com/en-us/library/thxezb7y.aspx
# /wd4127 = disable warning C4127 "conditional expression is constant"; see http://msdn.microsoft.com/en-us/library/6t66728h.aspx
# /wd4127 = disable warning C4127 "conditional expression is constant"; see http://msdn.microsoft.com/en-us/library/6t66728h.aspx
# /wd4355 = disable warning C4355 "'this' : used in base member initializer list"; http://msdn.microsoft.com/en-us/library/3c594ae3.aspx
# /wd4355 = disable warning C4355 "'this' : used in base member initializer list"; http://msdn.microsoft.com/en-us/library/3c594ae3.aspx
set
(
CMAKE_CXX_FLAGS
"/W3 /wd4127 /wd4355 /D_SCL_SECURE_NO_WARNINGS
${
CMAKE_CXX_FLAGS
}
"
)
set
(
yaml_cxx_flags
"/W3 /wd4127 /wd4355 /D_SCL_SECURE_NO_WARNINGS
${
yaml_cxx_flags
}
"
)
endif
()
endif
()
...
@@ -232,13 +269,9 @@ set(_INSTALL_DESTINATIONS
...
@@ -232,13 +269,9 @@ set(_INSTALL_DESTINATIONS
###
###
### Library
### Library
###
###
add_library
(
yaml-cpp
add_library
(
yaml-cpp
${
library_sources
}
)
${
sources
}
set_target_properties
(
yaml-cpp PROPERTIES
${
public_headers
}
COMPILE_FLAGS
"
${
yaml_c_flags
}
${
yaml_cxx_flags
}
"
${
private_headers
}
${
contrib_sources
}
${
contrib_public_headers
}
${
contrib_private_headers
}
)
)
set_target_properties
(
yaml-cpp PROPERTIES
set_target_properties
(
yaml-cpp PROPERTIES
...
@@ -286,3 +319,12 @@ if(YAML_CPP_BUILD_TOOLS)
...
@@ -286,3 +319,12 @@ if(YAML_CPP_BUILD_TOOLS)
add_subdirectory
(
test
)
add_subdirectory
(
test
)
add_subdirectory
(
util
)
add_subdirectory
(
util
)
endif
()
endif
()
### Formatting
if
(
${
CMAKE_BUILD_TOOL
}
MATCHES make OR
${
CMAKE_BUILD_TOOL
}
MATCHES gmake
)
get_property
(
all_sources GLOBAL PROPERTY SRCS_LIST
)
add_custom_target
(
format
COMMAND clang-format --style=file -i
${
all_sources
}
COMMENT
"Running clang-format"
VERBATIM
)
endif
()
\ No newline at end of file
test/CMakeLists.txt
View file @
dea3428c
set
(
gtest_force_shared_crt
${
MSVC_SHARED_RT
}
CACHE BOOL
set
(
gtest_force_shared_crt
${
MSVC_SHARED_RT
}
CACHE BOOL
"Use shared (DLL) run-time lib even when Google Test built as a static lib."
)
"Use shared (DLL) run-time lib even when Google Test built as a static lib."
)
add_subdirectory
(
gmock-1.7.0
)
add_subdirectory
(
gmock-1.7.0
)
include_directories
(
gmock-1.7.0/gtest/include
)
include_directories
(
SYSTEM
gmock-1.7.0/gtest/include
)
include_directories
(
gmock-1.7.0/include
)
include_directories
(
SYSTEM
gmock-1.7.0/include
)
if
(
WIN32 AND BUILD_SHARED_LIBS
)
if
(
WIN32 AND BUILD_SHARED_LIBS
)
add_definitions
(
"-DGTEST_LINKED_AS_SHARED_LIBRARY"
)
add_definitions
(
"-DGTEST_LINKED_AS_SHARED_LIBRARY"
)
endif
()
endif
()
if
(
"
${
CMAKE_CXX_COMPILER_ID
}
"
MATCHES
"GNU"
OR
"
${
CMAKE_CXX_COMPILER_ID
}
"
MATCHES
"Clang"
)
set
(
yaml_test_flags
"-Wno-c99-extensions -Wno-variadic-macros -Wno-sign-compare"
)
endif
()
file
(
GLOB test_headers [a-z_]*.h
)
file
(
GLOB test_headers [a-z_]*.h
)
file
(
GLOB test_sources [a-z_]*.cpp integration/[a-z_]*.cpp node/[a-z_]*.cpp
)
file
(
GLOB test_sources [a-z_]*.cpp integration/[a-z_]*.cpp node/[a-z_]*.cpp
)
file
(
GLOB test_new_api_sources new-api/[a-z]*.cpp
)
file
(
GLOB test_new_api_sources new-api/[a-z]*.cpp
)
list
(
APPEND test_sources
${
test_new_api_sources
}
)
list
(
APPEND test_sources
${
test_new_api_sources
}
)
add_sources
(
${
test_sources
}
${
test_headers
}
)
include_directories
(
${
YAML_CPP_SOURCE_DIR
}
/test
)
include_directories
(
${
YAML_CPP_SOURCE_DIR
}
/test
)
...
@@ -20,6 +26,9 @@ add_executable(run-tests
...
@@ -20,6 +26,9 @@ add_executable(run-tests
${
test_sources
}
${
test_sources
}
${
test_headers
}
${
test_headers
}
)
)
set_target_properties
(
run-tests PROPERTIES
COMPILE_FLAGS
"
${
yaml_c_flags
}
${
yaml_cxx_flags
}
${
yaml_test_flags
}
"
)
target_link_libraries
(
run-tests yaml-cpp gtest gmock
)
target_link_libraries
(
run-tests yaml-cpp gtest gmock
)
#add_test(yaml-reader-test run-tests)
#add_test(yaml-reader-test run-tests)
util/CMakeLists.txt
View file @
dea3428c
add_sources
(
parse.cpp
)
add_executable
(
parse parse.cpp
)
add_executable
(
parse parse.cpp
)
target_link_libraries
(
parse yaml-cpp
)
target_link_libraries
(
parse yaml-cpp
)
add_sources
(
sandbox.cpp
)
add_executable
(
sandbox sandbox.cpp
)
add_executable
(
sandbox sandbox.cpp
)
target_link_libraries
(
sandbox yaml-cpp
)
target_link_libraries
(
sandbox yaml-cpp
)
add_sources
(
read.cpp
)
add_executable
(
read read.cpp
)
add_executable
(
read read.cpp
)
target_link_libraries
(
read yaml-cpp
)
target_link_libraries
(
read yaml-cpp
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment