Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
googletest
Project
Overview
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
googletest
Commits
9c482422
Commit
9c482422
authored
Oct 05, 2010
by
zhanyong.wan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds a gtest_disable_pthreads CMake option; also fixes an include order problem…
Adds a gtest_disable_pthreads CMake option; also fixes an include order problem in the cmake script.
parent
e5974e3f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
35 deletions
+55
-35
CMakeLists.txt
CMakeLists.txt
+6
-6
internal_utils.cmake
cmake/internal_utils.cmake
+49
-29
No files found.
CMakeLists.txt
View file @
9c482422
########################################################################
########################################################################
# Experimental CMake build script for Google Test.
# CMake build script for Google Test.
#
# Consider this a prototype. It will change drastically. For now,
# this is only for people on the cutting edge.
#
#
# To run the tests for Google Test itself on Linux, use 'make test' or
# To run the tests for Google Test itself on Linux, use 'make test' or
# ctest. You can select which tests to run using 'ctest -R regex'.
# ctest. You can select which tests to run using 'ctest -R regex'.
...
@@ -23,6 +20,9 @@ option(gtest_build_tests "Build all of gtest's own tests." OFF)
...
@@ -23,6 +20,9 @@ option(gtest_build_tests "Build all of gtest's own tests." OFF)
option
(
gtest_build_samples
"Build gtest's sample programs."
OFF
)
option
(
gtest_build_samples
"Build gtest's sample programs."
OFF
)
option
(
gtest_disable_pthreads
"Disable uses of pthreads in gtest."
OFF
)
# Defines pre_project_set_up_hermetic_build() and set_up_hermetic_build().
include
(
cmake/hermetic_build.cmake OPTIONAL
)
include
(
cmake/hermetic_build.cmake OPTIONAL
)
if
(
COMMAND pre_project_set_up_hermetic_build
)
if
(
COMMAND pre_project_set_up_hermetic_build
)
...
@@ -46,10 +46,10 @@ if (COMMAND set_up_hermetic_build)
...
@@ -46,10 +46,10 @@ if (COMMAND set_up_hermetic_build)
set_up_hermetic_build
()
set_up_hermetic_build
()
endif
()
endif
()
# Define
s functions and variable
s used by Google Test.
# Define
helper functions and macro
s used by Google Test.
include
(
cmake/internal_utils.cmake
)
include
(
cmake/internal_utils.cmake
)
fix_default_settings
()
# Defined in internal_utils.cmake.
config_compiler_and_linker
()
# Defined in internal_utils.cmake.
# Where Google Test's .h files can be found.
# Where Google Test's .h files can be found.
include_directories
(
include_directories
(
...
...
cmake/internal_utils.cmake
View file @
9c482422
# NOTE: This file can be included both into Google Test's and Google Mock's
# Defines functions and macros useful for building Google Test and
# build scripts, so actions and functions defined here need to be
# Google Mock.
# idempotent.
#
# Note:
# Defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT.
#
find_package
(
Threads
)
# - This file will be run twice when building Google Mock (once via
# Google Test's CMakeLists.txt, and once via Google Mock's).
# Therefore it shouldn't have any side effects other than defining
# the functions and macros.
#
# - The functions/macros defined in this file may depend on Google
# Test and Google Mock's option() definitions, and thus must be
# called *after* the options have been defined.
# macro is required here, as inside a function string() will update
# Tweaks CMake's default compiler/linker settings to suit Google Test's needs.
# variables only at the function scope.
#
macro
(
fix_default_settings
)
# This must be a macro(), as inside a function string() can only
# update variables in the function scope.
macro
(
fix_default_compiler_settings_
)
if
(
MSVC
)
if
(
MSVC
)
# For MSVC, CMake sets certain flags to defaults we want to override.
# For MSVC, CMake sets certain flags to defaults we want to override.
# This replacement code is taken from sample in the CMake Wiki at
# This replacement code is taken from sample in the CMake Wiki at
...
@@ -33,11 +42,17 @@ macro(fix_default_settings)
...
@@ -33,11 +42,17 @@ macro(fix_default_settings)
endif
()
endif
()
endmacro
()
endmacro
()
# Defines the compiler/linker flags used to build gtest. You can
# Defines the compiler/linker flags used to build Google Test and
# tweak these definitions to suit your need. A variable's value is
# Google Mock. You can tweak these definitions to suit your need. A
# empty before it's explicitly assigned to.
# variable's value is empty before it's explicitly assigned to.
macro
(
config_compiler_and_linker
)
if
(
NOT gtest_disable_pthreads
)
# Defines CMAKE_USE_PTHREADS_INIT and CMAKE_THREAD_LIBS_INIT.
find_package
(
Threads
)
endif
()
if
(
MSVC
)
fix_default_compiler_settings_
()
if
(
MSVC
)
# Newlines inside flags variables break CMake's NMake generator.
# Newlines inside flags variables break CMake's NMake generator.
# TODO(vladl@google.com): Add -RTCs and -RTCu to debug builds.
# TODO(vladl@google.com): Add -RTCs and -RTCu to debug builds.
set
(
cxx_base_flags
"-GS -W4 -WX -wd4127 -wd4251 -wd4275 -nologo -J -Zi"
)
set
(
cxx_base_flags
"-GS -W4 -WX -wd4127 -wd4251 -wd4275 -nologo -J -Zi"
)
...
@@ -46,7 +61,7 @@ if (MSVC)
...
@@ -46,7 +61,7 @@ if (MSVC)
set
(
cxx_exception_flags
"-EHsc -D_HAS_EXCEPTIONS=1"
)
set
(
cxx_exception_flags
"-EHsc -D_HAS_EXCEPTIONS=1"
)
set
(
cxx_no_exception_flags
"-D_HAS_EXCEPTIONS=0"
)
set
(
cxx_no_exception_flags
"-D_HAS_EXCEPTIONS=0"
)
set
(
cxx_no_rtti_flags
"-GR-"
)
set
(
cxx_no_rtti_flags
"-GR-"
)
elseif
(
CMAKE_COMPILER_IS_GNUCXX
)
elseif
(
CMAKE_COMPILER_IS_GNUCXX
)
set
(
cxx_base_flags
"-Wall -Wshadow"
)
set
(
cxx_base_flags
"-Wall -Wshadow"
)
set
(
cxx_exception_flags
"-fexceptions"
)
set
(
cxx_exception_flags
"-fexceptions"
)
set
(
cxx_no_exception_flags
"-fno-exceptions"
)
set
(
cxx_no_exception_flags
"-fno-exceptions"
)
...
@@ -55,13 +70,13 @@ elseif (CMAKE_COMPILER_IS_GNUCXX)
...
@@ -55,13 +70,13 @@ elseif (CMAKE_COMPILER_IS_GNUCXX)
# explicitly.
# explicitly.
set
(
cxx_no_rtti_flags
"-fno-rtti -DGTEST_HAS_RTTI=0"
)
set
(
cxx_no_rtti_flags
"-fno-rtti -DGTEST_HAS_RTTI=0"
)
set
(
cxx_strict_flags
"-Wextra"
)
set
(
cxx_strict_flags
"-Wextra"
)
elseif
(
CMAKE_CXX_COMPILER_ID STREQUAL
"SunPro"
)
elseif
(
CMAKE_CXX_COMPILER_ID STREQUAL
"SunPro"
)
set
(
cxx_exception_flags
"-features=except"
)
set
(
cxx_exception_flags
"-features=except"
)
# Sun Pro doesn't provide macros to indicate whether exceptions and
# Sun Pro doesn't provide macros to indicate whether exceptions and
# RTTI are enabled, so we define GTEST_HAS_* explicitly.
# RTTI are enabled, so we define GTEST_HAS_* explicitly.
set
(
cxx_no_exception_flags
"-features=no%except -DGTEST_HAS_EXCEPTIONS=0"
)
set
(
cxx_no_exception_flags
"-features=no%except -DGTEST_HAS_EXCEPTIONS=0"
)
set
(
cxx_no_rtti_flags
"-features=no%rtti -DGTEST_HAS_RTTI=0"
)
set
(
cxx_no_rtti_flags
"-features=no%rtti -DGTEST_HAS_RTTI=0"
)
elseif
(
CMAKE_CXX_COMPILER_ID STREQUAL
"VisualAge"
OR
elseif
(
CMAKE_CXX_COMPILER_ID STREQUAL
"VisualAge"
OR
CMAKE_CXX_COMPILER_ID STREQUAL
"XL"
)
CMAKE_CXX_COMPILER_ID STREQUAL
"XL"
)
# CMake 2.8 changes Visual Age's compiler ID to "XL".
# CMake 2.8 changes Visual Age's compiler ID to "XL".
set
(
cxx_exception_flags
"-qeh"
)
set
(
cxx_exception_flags
"-qeh"
)
...
@@ -70,25 +85,26 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "VisualAge" OR
...
@@ -70,25 +85,26 @@ elseif (CMAKE_CXX_COMPILER_ID STREQUAL "VisualAge" OR
# whether RTTI is enabled. Therefore we define GTEST_HAS_RTTI
# whether RTTI is enabled. Therefore we define GTEST_HAS_RTTI
# explicitly.
# explicitly.
set
(
cxx_no_rtti_flags
"-qnortti -DGTEST_HAS_RTTI=0"
)
set
(
cxx_no_rtti_flags
"-qnortti -DGTEST_HAS_RTTI=0"
)
endif
()
endif
()
if
(
CMAKE_USE_PTHREADS_INIT
)
# The pthreads library is available
.
if
(
CMAKE_USE_PTHREADS_INIT
)
# The pthreads library is available and allowed
.
set
(
cxx_base_flags
"
${
cxx_base_flags
}
-DGTEST_HAS_PTHREAD=1"
)
set
(
cxx_base_flags
"
${
cxx_base_flags
}
-DGTEST_HAS_PTHREAD=1"
)
endif
()
else
()
set
(
cxx_base_flags
"
${
cxx_base_flags
}
-DGTEST_HAS_PTHREAD=0"
)
endif
()
# For building gtest's own tests and samples.
# For building gtest's own tests and samples.
set
(
cxx_exception
"
${
CMAKE_CXX_FLAGS
}
${
cxx_base_flags
}
${
cxx_exception_flags
}
"
)
set
(
cxx_exception
"
${
CMAKE_CXX_FLAGS
}
${
cxx_base_flags
}
${
cxx_exception_flags
}
"
)
set
(
cxx_no_exception
set
(
cxx_no_exception
"
${
CMAKE_CXX_FLAGS
}
${
cxx_base_flags
}
${
cxx_no_exception_flags
}
"
)
"
${
CMAKE_CXX_FLAGS
}
${
cxx_base_flags
}
${
cxx_no_exception_flags
}
"
)
set
(
cxx_default
"
${
cxx_exception
}
"
)
set
(
cxx_default
"
${
cxx_exception
}
"
)
set
(
cxx_no_rtti
"
${
cxx_default
}
${
cxx_no_rtti_flags
}
"
)
set
(
cxx_no_rtti
"
${
cxx_default
}
${
cxx_no_rtti_flags
}
"
)
set
(
cxx_use_own_tuple
"
${
cxx_default
}
-DGTEST_USE_OWN_TR1_TUPLE=1"
)
set
(
cxx_use_own_tuple
"
${
cxx_default
}
-DGTEST_USE_OWN_TR1_TUPLE=1"
)
# For building the gtest libraries.
# For building the gtest libraries.
set
(
cxx_strict
"
${
cxx_default
}
${
cxx_strict_flags
}
"
)
set
(
cxx_strict
"
${
cxx_default
}
${
cxx_strict_flags
}
"
)
endmacro
()
########################################################################
#
# Defines the gtest & gtest_main libraries. User tests should link
# Defines the gtest & gtest_main libraries. User tests should link
# with one of them.
# with one of them.
function
(
cxx_library_with_type name type cxx_flags
)
function
(
cxx_library_with_type name type cxx_flags
)
...
@@ -108,6 +124,10 @@ function(cxx_library_with_type name type cxx_flags)
...
@@ -108,6 +124,10 @@ function(cxx_library_with_type name type cxx_flags)
endif
()
endif
()
endfunction
()
endfunction
()
########################################################################
#
# Helper functions for creating build targets.
function
(
cxx_shared_library name cxx_flags
)
function
(
cxx_shared_library name cxx_flags
)
cxx_library_with_type
(
${
name
}
SHARED
"
${
cxx_flags
}
"
${
ARGN
}
)
cxx_library_with_type
(
${
name
}
SHARED
"
${
cxx_flags
}
"
${
ARGN
}
)
endfunction
()
endfunction
()
...
...
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