Describe the issue
CMake provides a series of variables (CMAKE_RUNTIME_OUTPUT_DIRECTORY, CMAKE_ARCHIVE_OUTPUT_DIRECTORY, CMAKE_LIBRARY_OUTPUT_DIRECTORY, CMAKE_PDB_OUTPUT_DIRECTORY, CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY). collectively CMAKE_<ARTIFACT>_OUTPUT_DIRECTORY, by which users can elect to tell the build where to place build-tree artifacts of a given artifact kind.
GTest does not respect these variables, as it hardcodes the underlying target properties in internal_utils.cmake::cxx_library_with_type
https://github.com/google/googletest/blame/d72f9c8aea6817cdf1ca0ac10887f328de7f3da2/googletest/cmake/internal_utils.cmake#L171-L177
This makes it difficult to configure where GTest artifacts are placed from the user side. It's not impossible because a consumer can override the properties on the created target(s), but it's obtuse and difficult to discern which targets need this treatment.
These are effectively the defaults, so we should simply not be setting the *_OUTPUT_DIRECTORY properties on gtest artifacts.
Steps to reproduce the problem
Build GTest with CMake, provide -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY to a value other than lib/. Observe that GTest artifacts are still in lib/
What version of GoogleTest are you using?
d72f9c8
What operating system and version are you using?
Ubuntu 24.04
What compiler and version are you using?
GCC 13
What build system are you using?
CMake 3.31
Additional context
No response
Describe the issue
CMake provides a series of variables (
CMAKE_RUNTIME_OUTPUT_DIRECTORY,CMAKE_ARCHIVE_OUTPUT_DIRECTORY,CMAKE_LIBRARY_OUTPUT_DIRECTORY,CMAKE_PDB_OUTPUT_DIRECTORY,CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY). collectivelyCMAKE_<ARTIFACT>_OUTPUT_DIRECTORY, by which users can elect to tell the build where to place build-tree artifacts of a given artifact kind.GTest does not respect these variables, as it hardcodes the underlying target properties in
internal_utils.cmake::cxx_library_with_typehttps://github.com/google/googletest/blame/d72f9c8aea6817cdf1ca0ac10887f328de7f3da2/googletest/cmake/internal_utils.cmake#L171-L177
This makes it difficult to configure where GTest artifacts are placed from the user side. It's not impossible because a consumer can override the properties on the created target(s), but it's obtuse and difficult to discern which targets need this treatment.
These are effectively the defaults, so we should simply not be setting the
*_OUTPUT_DIRECTORYproperties on gtest artifacts.Steps to reproduce the problem
Build GTest with CMake, provide
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORYto a value other thanlib/. Observe that GTest artifacts are still inlib/What version of GoogleTest are you using?
d72f9c8
What operating system and version are you using?
Ubuntu 24.04
What compiler and version are you using?
GCC 13
What build system are you using?
CMake 3.31
Additional context
No response