-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1260 from chuckatkins/fix-cmake-target-alias
Fix broken cmake imported target alias
- Loading branch information
Showing
13 changed files
with
133 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
@PACKAGE_INIT@ | ||
include(FindPackageHandleStandardArgs) | ||
set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG ${CMAKE_CURRENT_LIST_FILE}) | ||
find_package_handle_standard_args(@PROJECT_NAME@ CONFIG_MODE) | ||
|
||
if(NOT TARGET @PROJECT_NAME@::@NLOHMANN_JSON_TARGET_NAME@) | ||
include("${CMAKE_CURRENT_LIST_DIR}/@NLOHMANN_JSON_TARGETS_EXPORT_NAME@.cmake") | ||
if((NOT TARGET @NLOHMANN_JSON_TARGET_NAME@) AND | ||
(PACKAGE_FIND_VERSION VERSION_LESS 3.2.0)) | ||
add_library(@NLOHMANN_JSON_TARGET_NAME@ ALIAS @PROJECT_NAME@::@NLOHMANN_JSON_TARGET_NAME@) | ||
(NOT @PROJECT_NAME@_FIND_VERSION OR | ||
@PROJECT_NAME@_FIND_VERSION VERSION_LESS 3.2.0)) | ||
add_library(@NLOHMANN_JSON_TARGET_NAME@ INTERFACE IMPORTED) | ||
set_target_properties(@NLOHMANN_JSON_TARGET_NAME@ PROPERTIES | ||
INTERFACE_LINK_LIBRARIES @PROJECT_NAME@::@NLOHMANN_JSON_TARGET_NAME@ | ||
) | ||
endif() | ||
endif() | ||
check_required_components("@PROJECT_NAME@") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
add_test(NAME cmake_add_subdirectory_configure | ||
COMMAND ${CMAKE_COMMAND} | ||
-G "${CMAKE_GENERATOR}" | ||
-Dnlohmann_json_source=${PROJECT_SOURCE_DIR} | ||
${CMAKE_CURRENT_SOURCE_DIR}/project | ||
) | ||
add_test(NAME cmake_add_subdirectory_build | ||
COMMAND ${CMAKE_COMMAND} --build . | ||
) | ||
set_tests_properties(cmake_add_subdirectory_configure PROPERTIES | ||
FIXTURES_SETUP cmake_add_subdirectory | ||
) | ||
set_tests_properties(cmake_add_subdirectory_build PROPERTIES | ||
FIXTURES_REQUIRED cmake_add_subdirectory | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
|
||
project(DummyImport CXX) | ||
|
||
set(JSON_BuildTests OFF CACHE INTERNAL "") | ||
add_subdirectory(${nlohmann_json_source} | ||
${CMAKE_CURRENT_BINARY_DIR}/nlohmann_json) | ||
|
||
add_executable(with_namespace_target main.cpp) | ||
target_link_libraries(with_namespace_target nlohmann_json::nlohmann_json) | ||
|
||
add_executable(without_namespace_target main.cpp) | ||
target_link_libraries(without_namespace_target nlohmann_json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <nlohmann/json.hpp> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
nlohmann::json j; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
add_test(NAME cmake_import_configure | ||
COMMAND ${CMAKE_COMMAND} | ||
-G "${CMAKE_GENERATOR}" | ||
-Dnlohmann_json_DIR=${PROJECT_BINARY_DIR} | ||
${CMAKE_CURRENT_SOURCE_DIR}/project | ||
) | ||
add_test(NAME cmake_import_build | ||
COMMAND ${CMAKE_COMMAND} --build . | ||
) | ||
set_tests_properties(cmake_import_configure PROPERTIES | ||
FIXTURES_SETUP cmake_import | ||
) | ||
set_tests_properties(cmake_import_build PROPERTIES | ||
FIXTURES_REQUIRED cmake_import | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
|
||
project(DummyImport CXX) | ||
|
||
find_package(nlohmann_json REQUIRED) | ||
|
||
add_executable(with_namespace_target main.cpp) | ||
target_link_libraries(with_namespace_target nlohmann_json::nlohmann_json) | ||
|
||
add_executable(without_namespace_target main.cpp) | ||
target_link_libraries(without_namespace_target nlohmann_json) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <nlohmann/json.hpp> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
nlohmann::json j; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
add_test(NAME cmake_import_minver_configure | ||
COMMAND ${CMAKE_COMMAND} | ||
-G "${CMAKE_GENERATOR}" | ||
-Dnlohmann_json_DIR=${PROJECT_BINARY_DIR} | ||
${CMAKE_CURRENT_SOURCE_DIR}/project | ||
) | ||
add_test(NAME cmake_import_minver_build | ||
COMMAND ${CMAKE_COMMAND} --build . | ||
) | ||
set_tests_properties(cmake_import_minver_configure PROPERTIES | ||
FIXTURES_SETUP cmake_import_minver | ||
) | ||
set_tests_properties(cmake_import_minver_build PROPERTIES | ||
FIXTURES_REQUIRED cmake_import_minver | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.8) | ||
|
||
project(DummyImportMinVer CXX) | ||
|
||
find_package(nlohmann_json 3.2.0 REQUIRED) | ||
|
||
add_executable(with_namespace_target main.cpp) | ||
target_link_libraries(with_namespace_target nlohmann_json::nlohmann_json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <nlohmann/json.hpp> | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
nlohmann::json j; | ||
|
||
return 0; | ||
} |