From 9fc87c6343a5d448f04d7a9397beb95e3b85178e Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Thu, 11 Aug 2011 23:27:19 +0200 Subject: [PATCH] Add a test for the new --find-package mode Alex --- Tests/CMakeLists.txt | 2 ++ .../CMakeLists.txt | 22 +++++++++++++++++++ Tests/FindPackageModeMakefileTest/Makefile.in | 8 +++++++ Tests/FindPackageModeMakefileTest/main.cpp | 8 +++++++ 4 files changed, 40 insertions(+) create mode 100644 Tests/FindPackageModeMakefileTest/CMakeLists.txt create mode 100644 Tests/FindPackageModeMakefileTest/Makefile.in create mode 100644 Tests/FindPackageModeMakefileTest/main.cpp diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 2ad9a7759..a75b3df8f 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -46,6 +46,8 @@ IF(BUILD_TESTING) ADD_SUBDIRECTORY(CMakeLib) + ADD_SUBDIRECTORY(FindPackageModeMakefileTest) + # Collect a list of all test build directories. SET(TEST_BUILD_DIRS) diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt new file mode 100644 index 000000000..0be3783dc --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt @@ -0,0 +1,22 @@ + +if("${CMAKE_CXX_COMPILER_ID}" MATCHES GNU + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Intel + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES Clang + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES XL + OR "${CMAKE_CXX_COMPILER_ID}" MATCHES SunPro) + + find_package(PNG) + + # the test program links against the png lib, so test first whether it exists + if(PNG_FOUND) + + get_target_property(cmakeExecutable cmake LOCATION) + + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Makefile.in ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile @ONLY) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_BINARY_DIR}/main.cpp COPYONLY) + + add_test(FindPackageModeMakefileTest ${CMAKE_MAKE_PROGRAM} -f ${CMAKE_CURRENT_BINARY_DIR}/ConfMakefile -C ${CMAKE_CURRENT_BINARY_DIR} ) + + endif() + +endif() diff --git a/Tests/FindPackageModeMakefileTest/Makefile.in b/Tests/FindPackageModeMakefileTest/Makefile.in new file mode 100644 index 000000000..5105d9949 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/Makefile.in @@ -0,0 +1,8 @@ +all: clean pngtest + +pngtest: main.o + "@CMAKE_CXX_COMPILER@" -c `"@cmakeExecutable@" --find-package -DNAME=PNG -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=COMPILE` main.cpp + "@CMAKE_CXX_COMPILER@" -o pngtest main.o `"@cmakeExecutable@" --find-package -DNAME=PNG -DLANGUAGE=CXX -DCOMPILER_ID=@CMAKE_CXX_COMPILER_ID@ -DMODE=LINK` + +clean: + rm -f *.o pngtest diff --git a/Tests/FindPackageModeMakefileTest/main.cpp b/Tests/FindPackageModeMakefileTest/main.cpp new file mode 100644 index 000000000..b78542700 --- /dev/null +++ b/Tests/FindPackageModeMakefileTest/main.cpp @@ -0,0 +1,8 @@ +#include +#include + +int main() +{ + printf("PNG copyright: %s\n", png_get_copyright(NULL)); + return 0; +}