-
Notifications
You must be signed in to change notification settings - Fork 10k
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
Add CMake aliases #2429
Comments
Anything related to CMake is community supported. We do not use it internally and we are not in position to check. In general the maintainers would look for community consensus. |
My 2 cents,
|
set(cmake_package_name GTest) |
then used here:
googletest/googletest/CMakeLists.txt
Line 105 in 306f375
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
:
googletest/googletest/CMakeLists.txt
Lines 90 to 91 in 306f375
# 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:
googletest/googletest/CMakeLists.txt
Lines 128 to 129 in 306f375
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
:
googletest/googletest/cmake/internal_utils.cmake
Lines 197 to 203 in 306f375
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
:
googletest/googletest/cmake/internal_utils.cmake
Lines 147 to 150 in 306f375
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:
googletest/googlemock/CMakeLists.txt
Lines 89 to 107 in 7b1cf6d
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
googletest/googlemock/CMakeLists.txt
Lines 51 to 55 in 7b1cf6d
# 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:
googletest/googlemock/CMakeLists.txt
Line 121 in 306f375
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})
can i take this? |
Do whatever you think is best.
…On Mon, 7 Sep 2020, 17:57 Piotr Zarycki, ***@***.***> wrote:
can i take this?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#2429 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AN5J4ZX3WG3U3OE7TXYD323SETNSHANCNFSM4IPGCP7A>
.
|
Is there any progress on this? |
I think there is a pull request(#3155) for the same issue |
@derekmauro or @gennadiycivil please close this (since #3155 is merged). ps: I don't have right to this repo to close it myself... |
hey, I would like to contribute to this issue. Please assign this to me. |
I think the issue is resolved. |
GTest exports the following targets:
GTest::gtest
GTest::gtest_main
GTest::gmock
GTest::gmock_main
This targets should also be available when adding gtest with
add_subdirectory
(orFetchContent
), because this should behave the same way as adding GTest withfind_package
. So somewhere, we should add the aliases to these targets, i.e.I am not sure, where I should add these aliases.
The text was updated successfully, but these errors were encountered: