FindGTK2: Add unit test to check variables when run twice

This commit is contained in:
Daniele E. Domenichelli 2017-01-25 10:19:00 +01:00
parent 9702b3eefd
commit 4bc2c16b5d
4 changed files with 32 additions and 0 deletions

View File

@ -255,6 +255,11 @@ if(PKG_CONFIG_FOUND)
add_RunCMake_test(FindPkgConfig)
endif()
find_package(GTK2 QUIET)
if (GTK2_FOUND)
add_RunCMake_test(FindGTK2)
endif()
if("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
add_RunCMake_test(include_external_msproject)
if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([789]|10)" AND NOT CMAKE_VS_DEVENV_COMMAND)

View File

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.5)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.7)
project(testFindGTK2 C)
# First call
find_package(GTK2 REQUIRED)
# Backup variables
set(GTK2_LIBRARIES_BAK ${GTK2_LIBRARIES})
set(GTK2_TARGETS_BAK ${GTK2_TARGETS})
# Second call
find_package(GTK2 REQUIRED)
# Check variables
if(NOT "${GTK2_LIBRARIES_BAK}" STREQUAL "${GTK2_LIBRARIES}")
message(SEND_ERROR "GTK2_LIBRARIES is different:\nbefore: ${GTK2_LIBRARIES_BAK}\nafter: ${GTK2_LIBRARIES}")
endif()
if(NOT "${GTK2_TARGETS_BAK}" STREQUAL "${GTK2_TARGETS}")
message(SEND_ERROR "GTK2_TARGETS is different:\nbefore: ${GTK2_TARGETS_BAK}\nafter: ${GTK2_TARGETS}")
endif()

View File

@ -0,0 +1,3 @@
include(RunCMake)
run_cmake(FindGTK2RunTwice)