Skip to content

Conversation

@mrexodia
Copy link
Contributor

@mrexodia mrexodia commented Dec 4, 2024

[project]
name = "namespace"

[target.mylib]
type = "static"
sources = ["src/mylib.cpp"]

[target.myexe]
type = "executable"
sources = ["src/myexe.cpp"]
link-libraries = ["::mylibb"]

This will emit the following CMake:

if(NOT TARGET mylibb)
	message(FATAL_ERROR "Target \"mylibb\" referenced by \"myexe\" does not exist!")
endif()

target_link_libraries(
	mylibb
)

At configure-time it will error:

CMake Error at CMakeLists.txt:52 (message):
  Target "mylibb" referenced by "myexe" does not exist!

Relevant CMake issue: https://gitlab.kitware.com/cmake/cmake/-/issues/26497

@mrexodia mrexodia merged commit 49cdab3 into main Dec 4, 2024
8 checks passed
@mrexodia mrexodia deleted the namespace-targets branch December 4, 2024 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants