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

Surprising behavior with FetchContent #711

Open
samuelpmish opened this issue Dec 5, 2024 · 0 comments
Open

Surprising behavior with FetchContent #711

samuelpmish opened this issue Dec 5, 2024 · 0 comments

Comments

@samuelpmish
Copy link

If I have a simple CMake project

cmake_minimum_required(VERSION 3.18)
project(example_project LANGUAGES CXX)
add_executable(main main.cpp)

it defaults to putting the executables in the build directory.

% cd build && make
[ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o
[100%] Linking CXX executable main

When I tried adding RAJA as a dependency with FetchContent

cmake_minimum_required(VERSION 3.18)
project(example_project LANGUAGES CXX)

include(FetchContent)
FetchContent_Declare(
  raja
  URL            https://github.com/LLNL/RAJA/releases/download/v2024.07.0/RAJA-v2024.07.0.tar.gz
)
set(RAJA_ENABLE_TESTS OFF CACHE INTERNAL "")
set(RAJA_ENABLE_EXAMPLES OFF CACHE INTERNAL "")
set(RAJA_ENABLE_EXERCISES OFF CACHE INTERNAL "")
FetchContent_MakeAvailable(raja)

add_executable(main main.cpp)

RAJA built just fine, but I couldn't find my executables any more. When I looked more closely, I saw that they were being put in RAJA's output directory, which surprised me.

% cd build && make
[ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o
[100%] Linking CXX executable  _deps/raja-build/bin/main

I haven't looked into it too closely, but it seems like the cause is not RAJA after all, but BLT unconditionally setting the value of CMAKE_RUNTIME_OUTPUT_DIRECTORY here

blt/SetupBLT.cmake

Lines 158 to 162 in 5468efd

# Set the path where all the installed executables will go
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
${PROJECT_BINARY_DIR}/bin
CACHE PATH
"Directory where executables will go in the build tree")


As a user, my expectation is that bringing in a child project through FetchContent shouldn't result in changing the global settings of the parent project.

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

1 participant