Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
G
glog
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
glog
Commits
c0463b17
Commit
c0463b17
authored
Nov 10, 2019
by
Sergiu Deitsch
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added cmake package config unit test
parent
9a43cfb8
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
182 additions
and
8 deletions
+182
-8
.gitignore
.gitignore
+8
-8
CMakeLists.txt
CMakeLists.txt
+52
-0
GetCacheVariables.cmake
cmake/GetCacheVariables.cmake
+63
-0
TestInitPackageConfig.cmake
cmake/TestInitPackageConfig.cmake
+12
-0
TestPackageConfig.cmake
cmake/TestPackageConfig.cmake
+33
-0
CMakeLists.txt
src/package_config_unittest/working_config/CMakeLists.txt
+8
-0
glog_package_config.cc
...age_config_unittest/working_config/glog_package_config.cc
+6
-0
No files found.
.gitignore
View file @
c0463b17
/*.cmake
/*.filters
/*.sln
/*.vcxproj
autom4te.cache
glog-*.tar.gz
packages/rpm-unknown
packages/debian-*
bazel-*
CMakeCache.txt
CMakeFiles/
*.cmake
config.h
*.sln
*.vcxproj
*.filters
bazel-*
glog-*.tar.gz
packages/debian-*
packages/rpm-unknown
CMakeLists.txt
View file @
c0463b17
...
...
@@ -52,6 +52,7 @@ include (CMakePushCheckState)
include
(
CPack
)
include
(
CTest
)
include
(
DetermineGflagsNamespace
)
include
(
GetCacheVariables
)
include
(
GNUInstallDirs
)
set
(
CMAKE_DEBUG_POSTFIX d
)
...
...
@@ -703,6 +704,57 @@ if (BUILD_TESTING)
if
(
TARGET symbolize_unittest
)
add_test
(
NAME symbolize COMMAND symbolize_unittest
)
endif
(
TARGET symbolize_unittest
)
# Generate an initial cache
get_cache_variables
(
_CACHEVARS EXCLUDE CMAKE_MAKE_PROGRAM
)
set
(
_INITIAL_CACHE
${
CMAKE_CURRENT_BINARY_DIR
}
/test_package_config/glog_package_config_initial_cache.cmake
)
# Package config test
add_test
(
NAME cmake_package_config_init COMMAND
${
CMAKE_COMMAND
}
-DTEST_BINARY_DIR=
${
CMAKE_CURRENT_BINARY_DIR
}
/test_package_config
-DINITIAL_CACHE=
${
_INITIAL_CACHE
}
-DCACHEVARS=
${
_CACHEVARS
}
-P
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake/TestInitPackageConfig.cmake
)
add_test
(
NAME cmake_package_config_generate COMMAND
${
CMAKE_COMMAND
}
-DPATH=$ENV{PATH}
-DINITIAL_CACHE=
${
_INITIAL_CACHE
}
-DTEST_BINARY_DIR=
${
CMAKE_CURRENT_BINARY_DIR
}
/test_package_config/working_config
-DSOURCE_DIR=
${
CMAKE_CURRENT_SOURCE_DIR
}
/src/package_config_unittest/working_config
-DPACKAGE_DIR=
${
CMAKE_CURRENT_BINARY_DIR
}
-DGENERATOR=
${
CMAKE_GENERATOR
}
-P
${
CMAKE_CURRENT_SOURCE_DIR
}
/cmake/TestPackageConfig.cmake
)
add_test
(
NAME cmake_package_config_build COMMAND
${
CMAKE_COMMAND
}
--build
${
CMAKE_CURRENT_BINARY_DIR
}
/test_package_config/working_config
)
add_test
(
NAME cmake_package_config_cleanup COMMAND
${
CMAKE_COMMAND
}
-E
remove_directory
${
CMAKE_CURRENT_BINARY_DIR
}
/test_package_config
)
# Fixtures setup
set_tests_properties
(
cmake_package_config_init PROPERTIES FIXTURES_SETUP
cmake_package_config
)
set_tests_properties
(
cmake_package_config_generate PROPERTIES FIXTURES_SETUP
cmake_package_config_working
)
# Fixtures cleanup
set_tests_properties
(
cmake_package_config_cleanup PROPERTIES FIXTURES_CLEANUP
cmake_package_config
)
# Fixture requirements
set_tests_properties
(
cmake_package_config_generate PROPERTIES
FIXTURES_REQUIRED cmake_package_config
)
set_tests_properties
(
cmake_package_config_build PROPERTIES
FIXTURES_REQUIRED
"cmake_package_config;cmake_package_config_working"
)
endif
(
BUILD_TESTING
)
install
(
TARGETS glog
...
...
cmake/GetCacheVariables.cmake
0 → 100644
View file @
c0463b17
cmake_policy
(
PUSH
)
cmake_policy
(
VERSION 3.3
)
include
(
CMakeParseArguments
)
function
(
get_cache_variables _CACHEVARS
)
set
(
_SINGLE
)
set
(
_MULTI EXCLUDE
)
set
(
_OPTIONS
)
cmake_parse_arguments
(
_ARGS
"
${
_OPTIONS
}
"
"
${
_SINGLE
}
"
"
${
_MULTI
}
"
${
ARGS
}
${
ARGN
}
)
get_cmake_property
(
_VARIABLES VARIABLES
)
set
(
CACHEVARS
)
foreach
(
_VAR
${
_VARIABLES
}
)
if
(
DEFINED _ARGS_EXCLUDE
)
if
(
"
${
_VAR
}
"
IN_LIST _ARGS_EXCLUDE
)
continue
()
endif
(
"
${
_VAR
}
"
IN_LIST _ARGS_EXCLUDE
)
endif
(
DEFINED _ARGS_EXCLUDE
)
get_property
(
_CACHEVARTYPE CACHE
${
_VAR
}
PROPERTY TYPE
)
if
(
"
${
_CACHEVARTYPE
}
"
STREQUAL INTERNAL OR
"
${
_CACHEVARTYPE
}
"
STREQUAL STATIC OR
"
${
_CACHEVARTYPE
}
"
STREQUAL UNINITIALIZED
)
continue
()
endif
(
"
${
_CACHEVARTYPE
}
"
STREQUAL INTERNAL OR
"
${
_CACHEVARTYPE
}
"
STREQUAL STATIC OR
"
${
_CACHEVARTYPE
}
"
STREQUAL UNINITIALIZED
)
get_property
(
_CACHEVARVAL CACHE
${
_VAR
}
PROPERTY VALUE
)
if
(
"
${
_CACHEVARVAL
}
"
STREQUAL
""
)
continue
()
endif
(
"
${
_CACHEVARVAL
}
"
STREQUAL
""
)
get_property
(
_CACHEVARDOC CACHE
${
_VAR
}
PROPERTY HELPSTRING
)
# Escape " in values
string
(
REPLACE
"
\"
"
"
\\\"
"
_CACHEVARVAL
"
${
_CACHEVARVAL
}
"
)
# Escape " in help strings
string
(
REPLACE
"
\"
"
"
\\\"
"
_CACHEVARDOC
"
${
_CACHEVARDOC
}
"
)
# Escape ; in values
string
(
REPLACE
";"
"
\\\;
"
_CACHEVARVAL
"
${
_CACHEVARVAL
}
"
)
# Escape backslash in values
string
(
REGEX REPLACE
"
\\\\
([^
\"
])"
"
\\\\\\
1"
_CACHEVARVAL
"
${
_CACHEVARVAL
}
"
)
if
(
NOT
"
${
_CACHEVARTYPE
}
"
STREQUAL BOOL
)
set
(
_CACHEVARVAL
"
\"
${
_CACHEVARVAL
}
\"
"
)
endif
(
NOT
"
${
_CACHEVARTYPE
}
"
STREQUAL BOOL
)
if
(
NOT
"
${
_CACHEVARTYPE
}
"
STREQUAL
""
AND NOT
"
${
_CACHEVARVAL
}
"
STREQUAL
""
)
set
(
CACHEVARS
"
${
CACHEVARS
}
set (
${
_VAR
}
${
_CACHEVARVAL
}
CACHE
${
_CACHEVARTYPE
}
\"
${
_CACHEVARDOC
}
\"
)
\n
"
)
endif
(
NOT
"
${
_CACHEVARTYPE
}
"
STREQUAL
""
AND NOT
"
${
_CACHEVARVAL
}
"
STREQUAL
""
)
endforeach
(
_VAR
)
set
(
${
_CACHEVARS
}
${
CACHEVARS
}
PARENT_SCOPE
)
endfunction
(
get_cache_variables
)
cmake_policy
(
POP
)
cmake/TestInitPackageConfig.cmake
0 → 100644
View file @
c0463b17
# Create the build directory
execute_process
(
COMMAND
${
CMAKE_COMMAND
}
-E make_directory
${
TEST_BINARY_DIR
}
RESULT_VARIABLE _DIRECTORY_CREATED_SUCCEEDED
)
if
(
NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0
)
message
(
FATAL_ERROR
"Failed to create build directory"
)
endif
(
NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0
)
file
(
WRITE
${
INITIAL_CACHE
}
"
${
CACHEVARS
}
"
)
cmake/TestPackageConfig.cmake
0 → 100644
View file @
c0463b17
# Create the build directory
execute_process
(
COMMAND
${
CMAKE_COMMAND
}
-E make_directory
${
TEST_BINARY_DIR
}
RESULT_VARIABLE _DIRECTORY_CREATED_SUCCEEDED
)
if
(
NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0
)
message
(
FATAL_ERROR
"Failed to create build directory"
)
endif
(
NOT _DIRECTORY_CREATED_SUCCEEDED EQUAL 0
)
# Capture the PATH environment variable content set during project
# generation stage. This is required because later during the build stage
# the PATH is modified again (e.g., for MinGW AppVeyor CI builds) by adding
# back the directory containing git.exe. Incidently, the Git installation
# directory also contains sh.exe which causes MinGW Makefile generation to
# fail.
set
(
ENV{PATH}
${
PATH
}
)
# Run CMake
execute_process
(
COMMAND
${
CMAKE_COMMAND
}
-C
${
INITIAL_CACHE
}
-G
${
GENERATOR
}
-DCMAKE_PREFIX_PATH=
${
PACKAGE_DIR
}
-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON
-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON
${
SOURCE_DIR
}
WORKING_DIRECTORY
${
TEST_BINARY_DIR
}
RESULT_VARIABLE _GENERATE_SUCCEEDED
)
if
(
NOT _GENERATE_SUCCEEDED EQUAL 0
)
message
(
FATAL_ERROR
"Failed to generate project files using CMake"
)
endif
(
NOT _GENERATE_SUCCEEDED EQUAL 0
)
src/package_config_unittest/working_config/CMakeLists.txt
0 → 100644
View file @
c0463b17
cmake_minimum_required
(
VERSION 3.1
)
project
(
glog_package_config
)
find_package
(
glog REQUIRED NO_MODULE
)
add_executable
(
glog_package_config glog_package_config.cc
)
target_link_libraries
(
glog_package_config PRIVATE glog::glog
)
src/package_config_unittest/working_config/glog_package_config.cc
0 → 100644
View file @
c0463b17
#include <glog/logging.h>
int
main
(
int
/*argc*/
,
char
**
argv
)
{
google
::
InitGoogleLogging
(
argv
[
0
]);
}
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