I am trying to figure out exactly what this line is for in the cmake file of 
the github json project here -> 
https://github.com/nlohmann/json/blob/develop/CMakeLists.txt#L48

add_library(${PROJECT_NAME}::${NLOHMANN_JSON_TARGET_NAME} ALIAS 
${NLOHMANN_JSON_TARGET_NAME})

Specifically with this example, what does this allow in this cmake file that 
otherwise would not be possible?

The commit message where this line was added says,

"Enable target namespaces and build dir project config

CMake convention is to use a project namespace, i.e. Foo::, for imported
targets.  When multiple targets are imported from a project, this looks
like Foo::Bar1 Foo::Bar2, etc.  This adds the nlohmann_json:: namespace to
the exported target names.

This also allows the generated project config files to be used from the
build directory instead of just the install directory."
Removing this line appears to make no difference to any off the generated cmake 
files. I can still use find_package with the build directory in 
CMAKE_PREFIX-PATH with our without this line. Has something changed in cmake 
since this was added?
I am using cmake 3.10.2.
Thanks.
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to