Skip to content

Support ::mylib which that target that exists at configure-time#169

Merged
mrexodia merged 3 commits intomainfrom
namespace-targets
Dec 4, 2024
Merged

Support ::mylib which that target that exists at configure-time#169
mrexodia merged 3 commits intomainfrom
namespace-targets

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
@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.

1 participant