Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My 2 cents, #3546

Closed
Leestew81 opened this issue Sep 1, 2021 · 0 comments
Closed

My 2 cents, #3546

Leestew81 opened this issue Sep 1, 2021 · 0 comments

Comments

@Leestew81
Copy link

My 2 cents,

GTest namespace

First this CMake install NAMESPACE (GTest) is defined here:

set(cmake_package_name GTest)

then used here:
NAMESPACE ${cmake_package_name}::

To use this variable ${cmake_package_name}, it should be defined somewhere else IMHO...
Edit: should be defined before including internal_utils.cmake:

# Define helper functions and macros used by Google Test.
include(cmake/internal_utils.cmake)

gtest and gtest_main targets

these libraries are defined later using a custom function cxx_library:

cxx_library(gtest "${cxx_strict}" src/gtest-all.cc)
cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc)

which call cxx_library_with_type:

function(cxx_shared_library name cxx_flags)
cxx_library_with_type(${name} SHARED "${cxx_flags}" ${ARGN})
endfunction()
function(cxx_library name cxx_flags)
cxx_library_with_type(${name} "" "${cxx_flags}" ${ARGN})
endfunction()

which call the add_library:

function(cxx_library_with_type name type cxx_flags)
# type can be either STATIC or SHARED to denote a static or shared library.
# ARGN refers to additional arguments after 'cxx_flags'.
add_library(${name} ${type} ${ARGN})

so we should try to add the add_library(... ALIAS ...) to this function IMHO

gmock and gmock_main targets

pretty the same story:

if (MSVC)
cxx_library(gmock
"${cxx_strict}"
"${gtest_dir}/src/gtest-all.cc"
src/gmock-all.cc)
cxx_library(gmock_main
"${cxx_strict}"
"${gtest_dir}/src/gtest-all.cc"
src/gmock-all.cc
src/gmock_main.cc)
else()
cxx_library(gmock "${cxx_strict}" src/gmock-all.cc)
target_link_libraries(gmock PUBLIC gtest)
set_target_properties(gmock PROPERTIES VERSION ${GOOGLETEST_VERSION})
cxx_library(gmock_main "${cxx_strict}" src/gmock_main.cc)
target_link_libraries(gmock_main PUBLIC gmock)
set_target_properties(gmock_main PROPERTIES VERSION ${GOOGLETEST_VERSION})
endif()

note gmock CMakeLists.txt include the gtest one

# Instructs CMake to process Google Test's CMakeLists.txt and add its
# targets to the current scope. We are placing Google Test's binary
# directory in a subdirectory of our own as VC compilation may break
# if they are the same (the default).
add_subdirectory("${gtest_dir}" "${gmock_BINARY_DIR}/${gtest_dir}")

note: gmock install rules seems to use an other macro/function:

install_project(gmock gmock_main)

defined here (EDIT: just adding targets to the googletest target):
function(install_project)

(ed notice the of variable ${targets_export_name})

Originally posted by @Mizux in #2429 (comment)

@asoffer asoffer closed this as completed Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants