Add test for find_dependency macro.
This commit is contained in:
parent
6e6fbb0e43
commit
0bba365ff5
|
@ -381,6 +381,7 @@ if(BUILD_TESTING)
|
|||
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Module/ExternalData")
|
||||
|
||||
ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader)
|
||||
ADD_TEST_MACRO(Module.FindDependency FindDependency)
|
||||
|
||||
if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
cmake_minimum_required(VERSION 3.0)
|
||||
project(FindDependency)
|
||||
|
||||
set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/packages")
|
||||
|
||||
find_package(Pack1 REQUIRED)
|
||||
|
||||
add_executable(FindDependency main.cpp)
|
||||
target_link_libraries(FindDependency Pack1::Lib)
|
|
@ -0,0 +1,17 @@
|
|||
|
||||
#ifndef HAVE_PACK1
|
||||
#error Expected HAVE_PACK1
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_PACK2
|
||||
#error Expected HAVE_PACK2
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_PACK3
|
||||
#error Expected HAVE_PACK3
|
||||
#endif
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
find_dependency(Pack2 2.3)
|
||||
find_dependency(Pack3)
|
||||
|
||||
add_library(Pack1::Lib INTERFACE IMPORTED)
|
||||
set_property(TARGET Pack1::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK1)
|
||||
set_property(TARGET Pack1::Lib PROPERTY INTERFACE_LINK_LIBRARIES Pack2::Lib Pack3::Lib)
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
set(PACKAGE_VERSION "1.3")
|
||||
|
||||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
endif()
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
set(PACK2_VAR ON)
|
||||
|
||||
add_library(Pack2::Lib INTERFACE IMPORTED)
|
||||
set_property(TARGET Pack2::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK2)
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
set(PACKAGE_VERSION "2.4")
|
||||
|
||||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
endif()
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
set(PACK3_VAR ON)
|
||||
|
||||
add_library(Pack3::Lib INTERFACE IMPORTED)
|
||||
set_property(TARGET Pack3::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK3)
|
|
@ -0,0 +1,11 @@
|
|||
|
||||
set(PACKAGE_VERSION "1.4")
|
||||
|
||||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
endif()
|
Loading…
Reference in New Issue