directory-property BUILDSYSTEM_TARGETS and BINARY_DIR too limited: when multiple binary_dir for same source_dir
Hi,
the following shows that BUILDSYSTEM_TARGETS
is too limited, if it is a directory property which returns only a single value (opposed to a list!), since we can enter a source_dir multiple times with differing binary_dirs.
CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
project(go)
set(SFX v1)
add_subdirectory(src src1)
set(SFX v2)
add_subdirectory(src src2) ### enter same source_dir with differing binary_dir !!!!!!
get_property(bindir DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" PROPERTY BINARY_DIR)
message("### bindir == ${bindir}")
get_property(targets DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/src" PROPERTY BUILDSYSTEM_TARGETS)
message("### targets == ${targets}")
src/CMakeLists.txt
add_executable(go_${SFX} main.cpp)
target_compile_definitions(go_${SFX} PRIVATE THE_NAME=${SFX})
src/main.cpp
#include <iostream>
#define show1(name) #name
#define show(name) show1(name)
int main()
{
std::cout << show(THE_NAME) << std::endl;
}
Expected cmake-output:
### bindir == /home/me/proj/build/src1;/home/me/proj/build/src2
### targets == go_v1;go_v2
actual (unfortunate) cmake-output:
### bindir == /home/me/proj/build/src1
### targets == go_v1
In this scenario: how can I programatically get a list of all targets?
BUILDSYSTEM_TARGETS (and BINARY_DIR) should return a list, not a single value.
(Maby it would be good to have a new target BUILDSYSTEM_TARGETS_GLOBAL
which is global(!)., right?)
Edited by user706