Add documentation, comments. Move some 'Complex' sub-tests into 2 new 'Wrapping' and 'Testing' tests.

This commit is contained in:
Sebastien Barre 2002-01-19 21:24:55 -05:00
parent 30b3cc0755
commit c8d8e693cf
22 changed files with 575 additions and 345 deletions

View File

@ -12,28 +12,41 @@ ENDIF (CMAKE_ANSI_CXXFLAGS)
ADD_DEFINITIONS(-DCMAKE_IS_FUN) ADD_DEFINITIONS(-DCMAKE_IS_FUN)
#
# Include vars from a file and from a cache
#
IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake) IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake) INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake)
ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake) ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
LOAD_CACHE(${Complex_SOURCE_DIR}) LOAD_CACHE(${Complex_SOURCE_DIR})
#
# Configure file
# (plug vars to #define so that they can be tested)
#
CONFIGURE_FILE( CONFIGURE_FILE(
${Complex_SOURCE_DIR}/cmTestConfigure.h.in ${Complex_SOURCE_DIR}/cmTestConfigure.h.in
${Complex_BINARY_DIR}/cmTestConfigure.h) ${Complex_BINARY_DIR}/cmTestConfigure.h)
#
# Specify include and lib dirs
#
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
${Complex_BINARY_DIR} ${Complex_BINARY_DIR}
${Complex_SOURCE_DIR}/Library ${Complex_SOURCE_DIR}/Library
${Complex_SOURCE_DIR}/../../Source ${Complex_SOURCE_DIR}/../../Source
) )
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
LINK_DIRECTORIES( LINK_DIRECTORIES(
${Complex_BINARY_DIR}/Library ${Complex_BINARY_DIR}/Library
) )
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$") #
# Lib and exe path
#
SET (LIBRARY_OUTPUT_PATH SET (LIBRARY_OUTPUT_PATH
${Complex_BINARY_DIR}/bin/ CACHE PATH ${Complex_BINARY_DIR}/bin/ CACHE PATH
"Single output directory for building all libraries.") "Single output directory for building all libraries.")
@ -43,14 +56,8 @@ SET (EXECUTABLE_OUTPUT_PATH
"Single output directory for building all executables.") "Single output directory for building all executables.")
# #
# Where will executable tests be written ? # Create the libs and the main exe
# #
IF (EXECUTABLE_OUTPUT_PATH)
SET (CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
ELSE (EXECUTABLE_OUTPUT_PATH)
SET (CXX_TEST_PATH .)
ENDIF (EXECUTABLE_OUTPUT_PATH)
SUBDIRS(Library Executable) SUBDIRS(Library Executable)
SUBDIR_DEPENDS(Executable Library) SUBDIR_DEPENDS(Executable Library)
@ -68,30 +75,9 @@ ENDIF (NOT NO_EXEC_PROGRAM)
MARK_AS_ADVANCED(NO_EXEC_PROGRAM) MARK_AS_ADVANCED(NO_EXEC_PROGRAM)
MARK_AS_ADVANCED(CLEAR NO_EXEC_PROGRAM) MARK_AS_ADVANCED(CLEAR NO_EXEC_PROGRAM)
#
# More coverage
#
ABSTRACT_FILES(
ExtraSources/file1.cxx
)
INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
# #
# Create directory. # Create directory.
# The 'complex' executable will then test if this dir exists, # The 'complex' executable will then test if this dir exists,
# sadly it won't be able to remove it. # sadly it won't be able to remove it.
# #
MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir") MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir")
#
# Testing
#
ENABLE_TESTING()
#
# Test Cable
#
CABLE_CLASS_SET(Float float)
CABLE_CLASS_SET(Mesh "itk::Mesh<$Float>")

View File

@ -1,8 +1,14 @@
#
# Create exe.
#
ADD_EXECUTABLE(complex complex) ADD_EXECUTABLE(complex complex)
TARGET_LINK_LIBRARIES(complex CMakeTestLibrary) TARGET_LINK_LIBRARIES(complex CMakeTestLibrary)
TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared) TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared)
#
# Link to CMake lib
#
FIND_LIBRARY(CMAKE_LIB FIND_LIBRARY(CMAKE_LIB
CMakeLib CMakeLib
${Complex_BINARY_DIR}/../../Source ${Complex_BINARY_DIR}/../../Source
@ -12,15 +18,11 @@ FIND_LIBRARY(CMAKE_LIB
${Complex_BINARY_DIR}/../../Source/RelWithDebInfo) ${Complex_BINARY_DIR}/../../Source/RelWithDebInfo)
TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB}) TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
LINK_LIBRARIES(${CMAKE_LIB})
# #
# Testing # Extra coverage.Not used.
#
ADD_TEST(complex ${Complex_BINARY_DIR}/bin/complex)
#
# More coverage
# #
INSTALL_TARGETS(/tmp complex) INSTALL_TARGETS(/tmp complex)
INSTALL_PROGRAMS(/tmp complex) INSTALL_PROGRAMS(/tmp complex)
SOURCE_GROUP(A_GROUP ".cxx")

View File

@ -8,18 +8,24 @@
int passed = 0; int passed = 0;
int failed = 0; int failed = 0;
// ======================================================================
void Failed(const char* Message, const char* m2= "") void Failed(const char* Message, const char* m2= "")
{ {
std::cerr << "Failed: " << Message << m2 << "\n"; std::cerr << "Failed: " << Message << m2 << "\n";
failed++; failed++;
} }
// ======================================================================
void Passed(const char* Message, const char* m2="") void Passed(const char* Message, const char* m2="")
{ {
std::cout << "Passed: " << Message << m2 << "\n"; std::cout << "Passed: " << Message << m2 << "\n";
passed++; passed++;
} }
// ======================================================================
void TestAndRemoveFile(const char* filename) void TestAndRemoveFile(const char* filename)
{ {
if (!cmSystemTools::FileExists(filename)) if (!cmSystemTools::FileExists(filename))
@ -39,6 +45,8 @@ void TestAndRemoveFile(const char* filename)
} }
} }
// ======================================================================
void TestDir(const char* filename) void TestDir(const char* filename)
{ {
if (!cmSystemTools::FileExists(filename)) if (!cmSystemTools::FileExists(filename))
@ -58,6 +66,7 @@ void TestDir(const char* filename)
} }
} }
// ======================================================================
int main() int main()
{ {
@ -88,12 +97,18 @@ int main()
Passed("Call to file2 function returned 1."); Passed("Call to file2 function returned 1.");
} }
// ----------------------------------------------------------------------
// Test ADD_DEFINITIONS
#ifndef CMAKE_IS_FUN #ifndef CMAKE_IS_FUN
Failed("CMake is not fun, so it is broken and should be fixed."); Failed("CMake is not fun, so it is broken and should be fixed.");
#else #else
Passed("CMAKE_IS_FUN is defined."); Passed("CMAKE_IS_FUN is defined.");
#endif #endif
// ----------------------------------------------------------------------
// Test SET, VARIABLE_REQUIRES
#ifdef SHOULD_NOT_BE_DEFINED #ifdef SHOULD_NOT_BE_DEFINED
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined."); Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
#else #else
@ -106,6 +121,42 @@ int main()
Passed("SHOULD_BE_DEFINED is defined."); Passed("SHOULD_BE_DEFINED is defined.");
#endif #endif
#ifndef ONE_VAR
Failed("cmakedefine is broken, ONE_VAR is not defined.");
#else
Passed("ONE_VAR is defined.");
#endif
#ifndef ONE_VAR_IS_DEFINED
Failed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
"ONE_VAR_IS_DEFINED is not defined.");
#else
Passed("ONE_VAR_IS_DEFINED is defined.");
#endif
#ifdef ZERO_VAR
Failed("cmakedefine is broken, ZERO_VAR is defined.");
#else
Passed("ZERO_VAR is not defined.");
#endif
#ifndef STRING_VAR
Failed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
#else
if(strcmp(STRING_VAR, "CMake is great") != 0)
{
Failed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
STRING_VAR);
}
else
{
Passed("STRING_VAR == ", STRING_VAR);
}
#endif
// ----------------------------------------------------------------------
// Test various IF/ELSE combinations
#ifdef SHOULD_NOT_BE_DEFINED_AND #ifdef SHOULD_NOT_BE_DEFINED_AND
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined."); Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
#else #else
@ -142,38 +193,8 @@ int main()
Passed("SHOULD_BE_DEFINED_MATCHES is defined."); Passed("SHOULD_BE_DEFINED_MATCHES is defined.");
#endif #endif
#ifndef ONE_VAR // ----------------------------------------------------------------------
Failed("cmakedefine is broken, ONE_VAR is not defined."); // Test FOREACH
#else
Passed("ONE_VAR is defined.");
#endif
#ifndef ONE_VAR_IS_DEFINED
Failed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
"ONE_VAR_IS_DEFINED is not defined.");
#else
Passed("ONE_VAR_IS_DEFINED is defined.");
#endif
#ifdef ZERO_VAR
Failed("cmakedefine is broken, ZERO_VAR is defined.");
#else
Passed("ZERO_VAR is not defined.");
#endif
#ifndef STRING_VAR
Failed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
#else
if(strcmp(STRING_VAR, "CMake is great") != 0)
{
Failed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
STRING_VAR);
}
else
{
Passed("STRING_VAR == ", STRING_VAR);
}
#endif
#ifndef FOREACH_VAR1 #ifndef FOREACH_VAR1
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, " Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
@ -205,6 +226,9 @@ int main()
} }
#endif #endif
// ----------------------------------------------------------------------
// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
#ifndef FILENAME_VAR_PATH_NAME #ifndef FILENAME_VAR_PATH_NAME
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_PATH_NAME is not defined."); "FILENAME_VAR_PATH_NAME is not defined.");
@ -280,6 +304,9 @@ int main()
} }
#endif #endif
// ----------------------------------------------------------------------
// Test LOAD_CACHE
#ifndef CACHE_TEST_VAR1 #ifndef CACHE_TEST_VAR1
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
"CACHE_TEST_VAR1 is not defined."); "CACHE_TEST_VAR1 is not defined.");
@ -325,22 +352,26 @@ int main()
} }
#endif #endif
// ----------------------------------------------------------------------
// A post-build custom-command has been attached to the lib (see Library/). // A post-build custom-command has been attached to the lib (see Library/).
// It run ${CREATE_FILE_EXE} which will create the file // It runs ${CREATE_FILE_EXE} which will create a file.
// ${Complex_BINARY_DIR}/Library/postbuild.txt.
TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt"); TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt");
// ----------------------------------------------------------------------
// A custom target has been created (see Library/). // A custom target has been created (see Library/).
// It run ${CREATE_FILE_EXE} which will create the file // It runs ${CREATE_FILE_EXE} which will create a file.
// ${Complex_BINARY_DIR}/Library/custom_target1.txt.
TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt"); TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt");
// ----------------------------------------------------------------------
// A directory has been created. // A directory has been created.
TestDir(BINARY_DIR "/make_dir"); TestDir(BINARY_DIR "/make_dir");
// ----------------------------------------------------------------------
// Summary
std::cout << "Passed: " << passed << "\n"; std::cout << "Passed: " << passed << "\n";
if(failed) if(failed)
{ {

View File

@ -1,25 +1,30 @@
AUX_SOURCE_DIRECTORY(ExtraSources LibrarySources)
# SOURCE_FILES_REMOVE is used for Coverage
SOURCE_FILES(LibrarySources file2 GENERATED nonexisting_file)
SOURCE_FILES_REMOVE(LibrarySources GENERATED nonexisting_file)
ADD_LIBRARY(CMakeTestLibrary LibrarySources)
SOURCE_FILES(SharedLibrarySources sharedFile)
ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)
# #
# Small utility used to create file # Small utility used to create file
# UTILITY_SOURCE is used for coverage and for getting the exact name
# of the executable.
# #
UTILITY_SOURCE(CREATE_FILE_EXE create_file "." create_file.cxx) UTILITY_SOURCE(CREATE_FILE_EXE create_file "." create_file.cxx)
ADD_EXECUTABLE(create_file create_file.cxx) ADD_EXECUTABLE(create_file create_file.cxx)
#
# Create static library
# SOURCE_FILES_REMOVE is used for Coverage
#
AUX_SOURCE_DIRECTORY(ExtraSources LibrarySources)
SOURCE_FILES(LibrarySources file2 create_file.cxx GENERATED nonexisting_file)
SOURCE_FILES_REMOVE(LibrarySources create_file.cxx GENERATED nonexisting_file)
ADD_LIBRARY(CMakeTestLibrary LibrarySources)
#
# Create shared library
#
SOURCE_FILES(SharedLibrarySources sharedFile)
ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)
# #
# Attach a post-build custom-command to the lib. # Attach a post-build custom-command to the lib.
# It run ${CREATE_FILE_EXE} which will create the file # It runs ${CREATE_FILE_EXE} which will create a file.
# ${Complex_BINARY_DIR}/Library/postbuild.txt. # The 'complex' executable will then test if this file exists and remove it.
# The 'complex' executable will then test if this file exists,
# and remove it.
# #
ADD_DEPENDENCIES(CMakeTestLibraryShared create_file) ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
@ -29,11 +34,10 @@ ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
TARGET CMakeTestLibraryShared) TARGET CMakeTestLibraryShared)
# #
# Add custom target # Add a custom target.
# It run ${CREATE_FILE_EXE} which will create the file # It runs ${CREATE_FILE_EXE} which will create the file
# ${Complex_BINARY_DIR}/Library/custom_target1.txt. # It runs ${CREATE_FILE_EXE} which will create a file.
# The 'complex' executable will then test if this file exists, # The 'complex' executable will then test if this file exists and remove it.
# and remove it.
# #
ADD_CUSTOM_TARGET(custom_target1 ADD_CUSTOM_TARGET(custom_target1
ALL ALL
@ -42,6 +46,12 @@ ADD_CUSTOM_TARGET(custom_target1
ADD_DEPENDENCIES(custom_target1 create_file) ADD_DEPENDENCIES(custom_target1 create_file)
# More coverage #
# Extra coverage
#
ABSTRACT_FILES(
ExtraSources/file1.cxx
)
INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
SOURCE_GROUP(A_GROUP ".cxx")

View File

@ -1,3 +1,6 @@
#
# Test SET
#
SET (ZERO_VAR 0) SET (ZERO_VAR 0)
IF(ZERO_VAR) IF(ZERO_VAR)
@ -7,12 +10,18 @@ ELSE(ZERO_VAR)
ENDIF(ZERO_VAR) ENDIF(ZERO_VAR)
SET(ONE_VAR 1) SET(ONE_VAR 1)
SET(ONE_VAR2 1)
SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
#
# Test VARIABLE_REQUIRES
#
VARIABLE_REQUIRES(ONE_VAR VARIABLE_REQUIRES(ONE_VAR
ONE_VAR_IS_DEFINED ONE_VAR) ONE_VAR_IS_DEFINED ONE_VAR)
SET (ONE_VAR2 1) #
# Test various IF/ELSE combinations
#
IF(ONE_VAR AND ONE_VAR2) IF(ONE_VAR AND ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND) ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND)
ELSE(ONE_VAR AND ONE_VAR2) ELSE(ONE_VAR AND ONE_VAR2)
@ -25,32 +34,29 @@ ELSE(ZERO_VAR OR ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR) ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR)
ENDIF(ZERO_VAR OR ONE_VAR2) ENDIF(ZERO_VAR OR ONE_VAR2)
SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
IF(STRING_VAR MATCHES "^CMake") IF(STRING_VAR MATCHES "^CMake")
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES) ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES)
ELSE(STRING_VAR MATCHES "^CMake") ELSE(STRING_VAR MATCHES "^CMake")
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES) ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
ENDIF(STRING_VAR MATCHES "^CMake") ENDIF(STRING_VAR MATCHES "^CMake")
#
# Test FOREACH
#
FOREACH (INDEX 1 2) FOREACH (INDEX 1 2)
SET(FOREACH_VAR${INDEX} "VALUE${INDEX}") SET(FOREACH_VAR${INDEX} "VALUE${INDEX}")
ENDFOREACH(INDEX) ENDFOREACH(INDEX)
#
# Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
#
FIND_FILE(FILENAME_VAR "VarTests.cmake" ${Complex_SOURCE_DIR}) FIND_FILE(FILENAME_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
GET_FILENAME_COMPONENT(FILENAME_VAR_PATH ${FILENAME_VAR} PATH) GET_FILENAME_COMPONENT(FILENAME_VAR_PATH ${FILENAME_VAR} PATH)
GET_FILENAME_COMPONENT(FILENAME_VAR_PATH_NAME ${FILENAME_VAR_PATH} NAME) GET_FILENAME_COMPONENT(FILENAME_VAR_PATH_NAME ${FILENAME_VAR_PATH} NAME)
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME ${FILENAME_VAR} NAME) GET_FILENAME_COMPONENT(FILENAME_VAR_NAME ${FILENAME_VAR} NAME)
GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT) GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT)
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE) GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE CACHE)
FIND_PATH(PATH_VAR "VarTests.cmake" ${Complex_SOURCE_DIR}) FIND_PATH(PATH_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME) GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
# Coverage only
BUILD_COMMAND(BUILD_COMMAND_VAR ${CMAKE_MAKE_PROGRAM})
BUILD_NAME(BUILD_NAME_VAR)
SITE_NAME(SITE_NAME_VAR)

View File

@ -1,12 +1,18 @@
// Test SET, VARIABLE_REQUIRES
#cmakedefine ONE_VAR #cmakedefine ONE_VAR
#cmakedefine ONE_VAR_IS_DEFINED #cmakedefine ONE_VAR_IS_DEFINED
#cmakedefine ZERO_VAR #cmakedefine ZERO_VAR
#define STRING_VAR "${STRING_VAR}" #define STRING_VAR "${STRING_VAR}"
// Test FOREACH
#define FOREACH_VAR1 "${FOREACH_VAR1}" #define FOREACH_VAR1 "${FOREACH_VAR1}"
#define FOREACH_VAR2 "${FOREACH_VAR2}" #define FOREACH_VAR2 "${FOREACH_VAR2}"
// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
#define FILENAME_VAR_PATH_NAME "${FILENAME_VAR_PATH_NAME}" #define FILENAME_VAR_PATH_NAME "${FILENAME_VAR_PATH_NAME}"
#define FILENAME_VAR_NAME "${FILENAME_VAR_NAME}" #define FILENAME_VAR_NAME "${FILENAME_VAR_NAME}"
#define FILENAME_VAR_EXT "${FILENAME_VAR_EXT}" #define FILENAME_VAR_EXT "${FILENAME_VAR_EXT}"
@ -14,20 +20,18 @@
#define PATH_VAR_NAME "${PATH_VAR_NAME}" #define PATH_VAR_NAME "${PATH_VAR_NAME}"
#cmakedefine CMAKE_NO_STD_NAMESPACE // Test LOAD_CACHE
#cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
#cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}" #define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}" #define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}" #define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
// Test internal CMake vars from C++ flags
#cmakedefine CMAKE_NO_STD_NAMESPACE
#cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
#cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
// Needed to check for files // Needed to check for files
#define BINARY_DIR "${Complex_BINARY_DIR}" #define BINARY_DIR "${Complex_BINARY_DIR}"
// Coverage only
#define BUILD_COMMAND_VAR "${BUILD_COMMAND_VAR}"
#define BUILD_NAME_VAR "${BUILD_NAME_VAR}"
#define SITE_NAME_VAR "${SITE_NAME_VAR}"

View File

@ -12,28 +12,41 @@ ENDIF (CMAKE_ANSI_CXXFLAGS)
ADD_DEFINITIONS(-DCMAKE_IS_FUN) ADD_DEFINITIONS(-DCMAKE_IS_FUN)
#
# Include vars from a file and from a cache
#
IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake) IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake) INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake)
ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake) ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
LOAD_CACHE(${Complex_SOURCE_DIR}) LOAD_CACHE(${Complex_SOURCE_DIR})
#
# Configure file
# (plug vars to #define so that they can be tested)
#
CONFIGURE_FILE( CONFIGURE_FILE(
${Complex_SOURCE_DIR}/cmTestConfigure.h.in ${Complex_SOURCE_DIR}/cmTestConfigure.h.in
${Complex_BINARY_DIR}/cmTestConfigure.h) ${Complex_BINARY_DIR}/cmTestConfigure.h)
#
# Specify include and lib dirs
#
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
${Complex_BINARY_DIR} ${Complex_BINARY_DIR}
${Complex_SOURCE_DIR}/Library ${Complex_SOURCE_DIR}/Library
${Complex_SOURCE_DIR}/../../Source ${Complex_SOURCE_DIR}/../../Source
) )
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
LINK_DIRECTORIES( LINK_DIRECTORIES(
${Complex_BINARY_DIR}/Library ${Complex_BINARY_DIR}/Library
) )
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$") #
# Lib and exe path
#
SET (LIBRARY_OUTPUT_PATH SET (LIBRARY_OUTPUT_PATH
${Complex_BINARY_DIR}/bin/ CACHE PATH ${Complex_BINARY_DIR}/bin/ CACHE PATH
"Single output directory for building all libraries.") "Single output directory for building all libraries.")
@ -43,14 +56,8 @@ SET (EXECUTABLE_OUTPUT_PATH
"Single output directory for building all executables.") "Single output directory for building all executables.")
# #
# Where will executable tests be written ? # Create the libs and the main exe
# #
IF (EXECUTABLE_OUTPUT_PATH)
SET (CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
ELSE (EXECUTABLE_OUTPUT_PATH)
SET (CXX_TEST_PATH .)
ENDIF (EXECUTABLE_OUTPUT_PATH)
SUBDIRS(Library Executable) SUBDIRS(Library Executable)
SUBDIR_DEPENDS(Executable Library) SUBDIR_DEPENDS(Executable Library)
@ -68,30 +75,9 @@ ENDIF (NOT NO_EXEC_PROGRAM)
MARK_AS_ADVANCED(NO_EXEC_PROGRAM) MARK_AS_ADVANCED(NO_EXEC_PROGRAM)
MARK_AS_ADVANCED(CLEAR NO_EXEC_PROGRAM) MARK_AS_ADVANCED(CLEAR NO_EXEC_PROGRAM)
#
# More coverage
#
ABSTRACT_FILES(
ExtraSources/file1.cxx
)
INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
# #
# Create directory. # Create directory.
# The 'complex' executable will then test if this dir exists, # The 'complex' executable will then test if this dir exists,
# sadly it won't be able to remove it. # sadly it won't be able to remove it.
# #
MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir") MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir")
#
# Testing
#
ENABLE_TESTING()
#
# Test Cable
#
CABLE_CLASS_SET(Float float)
CABLE_CLASS_SET(Mesh "itk::Mesh<$Float>")

View File

@ -1,8 +1,14 @@
#
# Create exe.
#
ADD_EXECUTABLE(complex complex) ADD_EXECUTABLE(complex complex)
TARGET_LINK_LIBRARIES(complex CMakeTestLibrary) TARGET_LINK_LIBRARIES(complex CMakeTestLibrary)
TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared) TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared)
#
# Link to CMake lib
#
FIND_LIBRARY(CMAKE_LIB FIND_LIBRARY(CMAKE_LIB
CMakeLib CMakeLib
${Complex_BINARY_DIR}/../../Source ${Complex_BINARY_DIR}/../../Source
@ -12,15 +18,11 @@ FIND_LIBRARY(CMAKE_LIB
${Complex_BINARY_DIR}/../../Source/RelWithDebInfo) ${Complex_BINARY_DIR}/../../Source/RelWithDebInfo)
TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB}) TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
LINK_LIBRARIES(${CMAKE_LIB})
# #
# Testing # Extra coverage.Not used.
#
ADD_TEST(complex ${Complex_BINARY_DIR}/bin/complex)
#
# More coverage
# #
INSTALL_TARGETS(/tmp complex) INSTALL_TARGETS(/tmp complex)
INSTALL_PROGRAMS(/tmp complex) INSTALL_PROGRAMS(/tmp complex)
SOURCE_GROUP(A_GROUP ".cxx")

View File

@ -8,18 +8,24 @@
int passed = 0; int passed = 0;
int failed = 0; int failed = 0;
// ======================================================================
void Failed(const char* Message, const char* m2= "") void Failed(const char* Message, const char* m2= "")
{ {
std::cerr << "Failed: " << Message << m2 << "\n"; std::cerr << "Failed: " << Message << m2 << "\n";
failed++; failed++;
} }
// ======================================================================
void Passed(const char* Message, const char* m2="") void Passed(const char* Message, const char* m2="")
{ {
std::cout << "Passed: " << Message << m2 << "\n"; std::cout << "Passed: " << Message << m2 << "\n";
passed++; passed++;
} }
// ======================================================================
void TestAndRemoveFile(const char* filename) void TestAndRemoveFile(const char* filename)
{ {
if (!cmSystemTools::FileExists(filename)) if (!cmSystemTools::FileExists(filename))
@ -39,6 +45,8 @@ void TestAndRemoveFile(const char* filename)
} }
} }
// ======================================================================
void TestDir(const char* filename) void TestDir(const char* filename)
{ {
if (!cmSystemTools::FileExists(filename)) if (!cmSystemTools::FileExists(filename))
@ -58,6 +66,7 @@ void TestDir(const char* filename)
} }
} }
// ======================================================================
int main() int main()
{ {
@ -88,12 +97,18 @@ int main()
Passed("Call to file2 function returned 1."); Passed("Call to file2 function returned 1.");
} }
// ----------------------------------------------------------------------
// Test ADD_DEFINITIONS
#ifndef CMAKE_IS_FUN #ifndef CMAKE_IS_FUN
Failed("CMake is not fun, so it is broken and should be fixed."); Failed("CMake is not fun, so it is broken and should be fixed.");
#else #else
Passed("CMAKE_IS_FUN is defined."); Passed("CMAKE_IS_FUN is defined.");
#endif #endif
// ----------------------------------------------------------------------
// Test SET, VARIABLE_REQUIRES
#ifdef SHOULD_NOT_BE_DEFINED #ifdef SHOULD_NOT_BE_DEFINED
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined."); Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
#else #else
@ -106,6 +121,42 @@ int main()
Passed("SHOULD_BE_DEFINED is defined."); Passed("SHOULD_BE_DEFINED is defined.");
#endif #endif
#ifndef ONE_VAR
Failed("cmakedefine is broken, ONE_VAR is not defined.");
#else
Passed("ONE_VAR is defined.");
#endif
#ifndef ONE_VAR_IS_DEFINED
Failed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
"ONE_VAR_IS_DEFINED is not defined.");
#else
Passed("ONE_VAR_IS_DEFINED is defined.");
#endif
#ifdef ZERO_VAR
Failed("cmakedefine is broken, ZERO_VAR is defined.");
#else
Passed("ZERO_VAR is not defined.");
#endif
#ifndef STRING_VAR
Failed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
#else
if(strcmp(STRING_VAR, "CMake is great") != 0)
{
Failed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
STRING_VAR);
}
else
{
Passed("STRING_VAR == ", STRING_VAR);
}
#endif
// ----------------------------------------------------------------------
// Test various IF/ELSE combinations
#ifdef SHOULD_NOT_BE_DEFINED_AND #ifdef SHOULD_NOT_BE_DEFINED_AND
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined."); Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
#else #else
@ -142,38 +193,8 @@ int main()
Passed("SHOULD_BE_DEFINED_MATCHES is defined."); Passed("SHOULD_BE_DEFINED_MATCHES is defined.");
#endif #endif
#ifndef ONE_VAR // ----------------------------------------------------------------------
Failed("cmakedefine is broken, ONE_VAR is not defined."); // Test FOREACH
#else
Passed("ONE_VAR is defined.");
#endif
#ifndef ONE_VAR_IS_DEFINED
Failed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
"ONE_VAR_IS_DEFINED is not defined.");
#else
Passed("ONE_VAR_IS_DEFINED is defined.");
#endif
#ifdef ZERO_VAR
Failed("cmakedefine is broken, ZERO_VAR is defined.");
#else
Passed("ZERO_VAR is not defined.");
#endif
#ifndef STRING_VAR
Failed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
#else
if(strcmp(STRING_VAR, "CMake is great") != 0)
{
Failed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
STRING_VAR);
}
else
{
Passed("STRING_VAR == ", STRING_VAR);
}
#endif
#ifndef FOREACH_VAR1 #ifndef FOREACH_VAR1
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, " Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
@ -205,6 +226,9 @@ int main()
} }
#endif #endif
// ----------------------------------------------------------------------
// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
#ifndef FILENAME_VAR_PATH_NAME #ifndef FILENAME_VAR_PATH_NAME
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_PATH_NAME is not defined."); "FILENAME_VAR_PATH_NAME is not defined.");
@ -280,6 +304,9 @@ int main()
} }
#endif #endif
// ----------------------------------------------------------------------
// Test LOAD_CACHE
#ifndef CACHE_TEST_VAR1 #ifndef CACHE_TEST_VAR1
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
"CACHE_TEST_VAR1 is not defined."); "CACHE_TEST_VAR1 is not defined.");
@ -325,22 +352,26 @@ int main()
} }
#endif #endif
// ----------------------------------------------------------------------
// A post-build custom-command has been attached to the lib (see Library/). // A post-build custom-command has been attached to the lib (see Library/).
// It run ${CREATE_FILE_EXE} which will create the file // It runs ${CREATE_FILE_EXE} which will create a file.
// ${Complex_BINARY_DIR}/Library/postbuild.txt.
TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt"); TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt");
// ----------------------------------------------------------------------
// A custom target has been created (see Library/). // A custom target has been created (see Library/).
// It run ${CREATE_FILE_EXE} which will create the file // It runs ${CREATE_FILE_EXE} which will create a file.
// ${Complex_BINARY_DIR}/Library/custom_target1.txt.
TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt"); TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt");
// ----------------------------------------------------------------------
// A directory has been created. // A directory has been created.
TestDir(BINARY_DIR "/make_dir"); TestDir(BINARY_DIR "/make_dir");
// ----------------------------------------------------------------------
// Summary
std::cout << "Passed: " << passed << "\n"; std::cout << "Passed: " << passed << "\n";
if(failed) if(failed)
{ {

View File

@ -1,25 +1,30 @@
AUX_SOURCE_DIRECTORY(ExtraSources LibrarySources)
# SOURCE_FILES_REMOVE is used for Coverage
SOURCE_FILES(LibrarySources file2 GENERATED nonexisting_file)
SOURCE_FILES_REMOVE(LibrarySources GENERATED nonexisting_file)
ADD_LIBRARY(CMakeTestLibrary LibrarySources)
SOURCE_FILES(SharedLibrarySources sharedFile)
ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)
# #
# Small utility used to create file # Small utility used to create file
# UTILITY_SOURCE is used for coverage and for getting the exact name
# of the executable.
# #
UTILITY_SOURCE(CREATE_FILE_EXE create_file "." create_file.cxx) UTILITY_SOURCE(CREATE_FILE_EXE create_file "." create_file.cxx)
ADD_EXECUTABLE(create_file create_file.cxx) ADD_EXECUTABLE(create_file create_file.cxx)
#
# Create static library
# SOURCE_FILES_REMOVE is used for Coverage
#
AUX_SOURCE_DIRECTORY(ExtraSources LibrarySources)
SOURCE_FILES(LibrarySources file2 create_file.cxx GENERATED nonexisting_file)
SOURCE_FILES_REMOVE(LibrarySources create_file.cxx GENERATED nonexisting_file)
ADD_LIBRARY(CMakeTestLibrary LibrarySources)
#
# Create shared library
#
SOURCE_FILES(SharedLibrarySources sharedFile)
ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)
# #
# Attach a post-build custom-command to the lib. # Attach a post-build custom-command to the lib.
# It run ${CREATE_FILE_EXE} which will create the file # It runs ${CREATE_FILE_EXE} which will create a file.
# ${Complex_BINARY_DIR}/Library/postbuild.txt. # The 'complex' executable will then test if this file exists and remove it.
# The 'complex' executable will then test if this file exists,
# and remove it.
# #
ADD_DEPENDENCIES(CMakeTestLibraryShared create_file) ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
@ -29,11 +34,10 @@ ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
TARGET CMakeTestLibraryShared) TARGET CMakeTestLibraryShared)
# #
# Add custom target # Add a custom target.
# It run ${CREATE_FILE_EXE} which will create the file # It runs ${CREATE_FILE_EXE} which will create the file
# ${Complex_BINARY_DIR}/Library/custom_target1.txt. # It runs ${CREATE_FILE_EXE} which will create a file.
# The 'complex' executable will then test if this file exists, # The 'complex' executable will then test if this file exists and remove it.
# and remove it.
# #
ADD_CUSTOM_TARGET(custom_target1 ADD_CUSTOM_TARGET(custom_target1
ALL ALL
@ -42,6 +46,12 @@ ADD_CUSTOM_TARGET(custom_target1
ADD_DEPENDENCIES(custom_target1 create_file) ADD_DEPENDENCIES(custom_target1 create_file)
# More coverage #
# Extra coverage
#
ABSTRACT_FILES(
ExtraSources/file1.cxx
)
INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
SOURCE_GROUP(A_GROUP ".cxx")

View File

@ -1,3 +1,6 @@
#
# Test SET
#
SET (ZERO_VAR 0) SET (ZERO_VAR 0)
IF(ZERO_VAR) IF(ZERO_VAR)
@ -7,12 +10,18 @@ ELSE(ZERO_VAR)
ENDIF(ZERO_VAR) ENDIF(ZERO_VAR)
SET(ONE_VAR 1) SET(ONE_VAR 1)
SET(ONE_VAR2 1)
SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
#
# Test VARIABLE_REQUIRES
#
VARIABLE_REQUIRES(ONE_VAR VARIABLE_REQUIRES(ONE_VAR
ONE_VAR_IS_DEFINED ONE_VAR) ONE_VAR_IS_DEFINED ONE_VAR)
SET (ONE_VAR2 1) #
# Test various IF/ELSE combinations
#
IF(ONE_VAR AND ONE_VAR2) IF(ONE_VAR AND ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND) ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND)
ELSE(ONE_VAR AND ONE_VAR2) ELSE(ONE_VAR AND ONE_VAR2)
@ -25,32 +34,29 @@ ELSE(ZERO_VAR OR ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR) ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR)
ENDIF(ZERO_VAR OR ONE_VAR2) ENDIF(ZERO_VAR OR ONE_VAR2)
SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
IF(STRING_VAR MATCHES "^CMake") IF(STRING_VAR MATCHES "^CMake")
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES) ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES)
ELSE(STRING_VAR MATCHES "^CMake") ELSE(STRING_VAR MATCHES "^CMake")
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES) ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
ENDIF(STRING_VAR MATCHES "^CMake") ENDIF(STRING_VAR MATCHES "^CMake")
#
# Test FOREACH
#
FOREACH (INDEX 1 2) FOREACH (INDEX 1 2)
SET(FOREACH_VAR${INDEX} "VALUE${INDEX}") SET(FOREACH_VAR${INDEX} "VALUE${INDEX}")
ENDFOREACH(INDEX) ENDFOREACH(INDEX)
#
# Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
#
FIND_FILE(FILENAME_VAR "VarTests.cmake" ${Complex_SOURCE_DIR}) FIND_FILE(FILENAME_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
GET_FILENAME_COMPONENT(FILENAME_VAR_PATH ${FILENAME_VAR} PATH) GET_FILENAME_COMPONENT(FILENAME_VAR_PATH ${FILENAME_VAR} PATH)
GET_FILENAME_COMPONENT(FILENAME_VAR_PATH_NAME ${FILENAME_VAR_PATH} NAME) GET_FILENAME_COMPONENT(FILENAME_VAR_PATH_NAME ${FILENAME_VAR_PATH} NAME)
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME ${FILENAME_VAR} NAME) GET_FILENAME_COMPONENT(FILENAME_VAR_NAME ${FILENAME_VAR} NAME)
GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT) GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT)
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE) GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE CACHE)
FIND_PATH(PATH_VAR "VarTests.cmake" ${Complex_SOURCE_DIR}) FIND_PATH(PATH_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME) GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
# Coverage only
BUILD_COMMAND(BUILD_COMMAND_VAR ${CMAKE_MAKE_PROGRAM})
BUILD_NAME(BUILD_NAME_VAR)
SITE_NAME(SITE_NAME_VAR)

View File

@ -1,12 +1,18 @@
// Test SET, VARIABLE_REQUIRES
#cmakedefine ONE_VAR #cmakedefine ONE_VAR
#cmakedefine ONE_VAR_IS_DEFINED #cmakedefine ONE_VAR_IS_DEFINED
#cmakedefine ZERO_VAR #cmakedefine ZERO_VAR
#define STRING_VAR "${STRING_VAR}" #define STRING_VAR "${STRING_VAR}"
// Test FOREACH
#define FOREACH_VAR1 "${FOREACH_VAR1}" #define FOREACH_VAR1 "${FOREACH_VAR1}"
#define FOREACH_VAR2 "${FOREACH_VAR2}" #define FOREACH_VAR2 "${FOREACH_VAR2}"
// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
#define FILENAME_VAR_PATH_NAME "${FILENAME_VAR_PATH_NAME}" #define FILENAME_VAR_PATH_NAME "${FILENAME_VAR_PATH_NAME}"
#define FILENAME_VAR_NAME "${FILENAME_VAR_NAME}" #define FILENAME_VAR_NAME "${FILENAME_VAR_NAME}"
#define FILENAME_VAR_EXT "${FILENAME_VAR_EXT}" #define FILENAME_VAR_EXT "${FILENAME_VAR_EXT}"
@ -14,20 +20,18 @@
#define PATH_VAR_NAME "${PATH_VAR_NAME}" #define PATH_VAR_NAME "${PATH_VAR_NAME}"
#cmakedefine CMAKE_NO_STD_NAMESPACE // Test LOAD_CACHE
#cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
#cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}" #define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}" #define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}" #define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
// Test internal CMake vars from C++ flags
#cmakedefine CMAKE_NO_STD_NAMESPACE
#cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
#cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
// Needed to check for files // Needed to check for files
#define BINARY_DIR "${Complex_BINARY_DIR}" #define BINARY_DIR "${Complex_BINARY_DIR}"
// Coverage only
#define BUILD_COMMAND_VAR "${BUILD_COMMAND_VAR}"
#define BUILD_NAME_VAR "${BUILD_NAME_VAR}"
#define SITE_NAME_VAR "${SITE_NAME_VAR}"

View File

@ -12,28 +12,41 @@ ENDIF (CMAKE_ANSI_CXXFLAGS)
ADD_DEFINITIONS(-DCMAKE_IS_FUN) ADD_DEFINITIONS(-DCMAKE_IS_FUN)
#
# Include vars from a file and from a cache
#
IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake) IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake) INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake)
ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake) ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
LOAD_CACHE(${Complex_SOURCE_DIR}) LOAD_CACHE(${Complex_SOURCE_DIR})
#
# Configure file
# (plug vars to #define so that they can be tested)
#
CONFIGURE_FILE( CONFIGURE_FILE(
${Complex_SOURCE_DIR}/cmTestConfigure.h.in ${Complex_SOURCE_DIR}/cmTestConfigure.h.in
${Complex_BINARY_DIR}/cmTestConfigure.h) ${Complex_BINARY_DIR}/cmTestConfigure.h)
#
# Specify include and lib dirs
#
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
${Complex_BINARY_DIR} ${Complex_BINARY_DIR}
${Complex_SOURCE_DIR}/Library ${Complex_SOURCE_DIR}/Library
${Complex_SOURCE_DIR}/../../Source ${Complex_SOURCE_DIR}/../../Source
) )
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$")
LINK_DIRECTORIES( LINK_DIRECTORIES(
${Complex_BINARY_DIR}/Library ${Complex_BINARY_DIR}/Library
) )
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$") #
# Lib and exe path
#
SET (LIBRARY_OUTPUT_PATH SET (LIBRARY_OUTPUT_PATH
${Complex_BINARY_DIR}/bin/ CACHE PATH ${Complex_BINARY_DIR}/bin/ CACHE PATH
"Single output directory for building all libraries.") "Single output directory for building all libraries.")
@ -43,14 +56,8 @@ SET (EXECUTABLE_OUTPUT_PATH
"Single output directory for building all executables.") "Single output directory for building all executables.")
# #
# Where will executable tests be written ? # Create the libs and the main exe
# #
IF (EXECUTABLE_OUTPUT_PATH)
SET (CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
ELSE (EXECUTABLE_OUTPUT_PATH)
SET (CXX_TEST_PATH .)
ENDIF (EXECUTABLE_OUTPUT_PATH)
SUBDIRS(Library Executable) SUBDIRS(Library Executable)
SUBDIR_DEPENDS(Executable Library) SUBDIR_DEPENDS(Executable Library)
@ -68,30 +75,9 @@ ENDIF (NOT NO_EXEC_PROGRAM)
MARK_AS_ADVANCED(NO_EXEC_PROGRAM) MARK_AS_ADVANCED(NO_EXEC_PROGRAM)
MARK_AS_ADVANCED(CLEAR NO_EXEC_PROGRAM) MARK_AS_ADVANCED(CLEAR NO_EXEC_PROGRAM)
#
# More coverage
#
ABSTRACT_FILES(
ExtraSources/file1.cxx
)
INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
# #
# Create directory. # Create directory.
# The 'complex' executable will then test if this dir exists, # The 'complex' executable will then test if this dir exists,
# sadly it won't be able to remove it. # sadly it won't be able to remove it.
# #
MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir") MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir")
#
# Testing
#
ENABLE_TESTING()
#
# Test Cable
#
CABLE_CLASS_SET(Float float)
CABLE_CLASS_SET(Mesh "itk::Mesh<$Float>")

View File

@ -1,8 +1,14 @@
#
# Create exe.
#
ADD_EXECUTABLE(complex complex) ADD_EXECUTABLE(complex complex)
TARGET_LINK_LIBRARIES(complex CMakeTestLibrary) TARGET_LINK_LIBRARIES(complex CMakeTestLibrary)
TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared) TARGET_LINK_LIBRARIES(complex CMakeTestLibraryShared)
#
# Link to CMake lib
#
FIND_LIBRARY(CMAKE_LIB FIND_LIBRARY(CMAKE_LIB
CMakeLib CMakeLib
${Complex_BINARY_DIR}/../../Source ${Complex_BINARY_DIR}/../../Source
@ -12,15 +18,11 @@ FIND_LIBRARY(CMAKE_LIB
${Complex_BINARY_DIR}/../../Source/RelWithDebInfo) ${Complex_BINARY_DIR}/../../Source/RelWithDebInfo)
TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB}) TARGET_LINK_LIBRARIES(complex ${CMAKE_LIB})
LINK_LIBRARIES(${CMAKE_LIB})
# #
# Testing # Extra coverage.Not used.
#
ADD_TEST(complex ${Complex_BINARY_DIR}/bin/complex)
#
# More coverage
# #
INSTALL_TARGETS(/tmp complex) INSTALL_TARGETS(/tmp complex)
INSTALL_PROGRAMS(/tmp complex) INSTALL_PROGRAMS(/tmp complex)
SOURCE_GROUP(A_GROUP ".cxx")

View File

@ -8,18 +8,24 @@
int passed = 0; int passed = 0;
int failed = 0; int failed = 0;
// ======================================================================
void Failed(const char* Message, const char* m2= "") void Failed(const char* Message, const char* m2= "")
{ {
std::cerr << "Failed: " << Message << m2 << "\n"; std::cerr << "Failed: " << Message << m2 << "\n";
failed++; failed++;
} }
// ======================================================================
void Passed(const char* Message, const char* m2="") void Passed(const char* Message, const char* m2="")
{ {
std::cout << "Passed: " << Message << m2 << "\n"; std::cout << "Passed: " << Message << m2 << "\n";
passed++; passed++;
} }
// ======================================================================
void TestAndRemoveFile(const char* filename) void TestAndRemoveFile(const char* filename)
{ {
if (!cmSystemTools::FileExists(filename)) if (!cmSystemTools::FileExists(filename))
@ -39,6 +45,8 @@ void TestAndRemoveFile(const char* filename)
} }
} }
// ======================================================================
void TestDir(const char* filename) void TestDir(const char* filename)
{ {
if (!cmSystemTools::FileExists(filename)) if (!cmSystemTools::FileExists(filename))
@ -58,6 +66,7 @@ void TestDir(const char* filename)
} }
} }
// ======================================================================
int main() int main()
{ {
@ -88,12 +97,18 @@ int main()
Passed("Call to file2 function returned 1."); Passed("Call to file2 function returned 1.");
} }
// ----------------------------------------------------------------------
// Test ADD_DEFINITIONS
#ifndef CMAKE_IS_FUN #ifndef CMAKE_IS_FUN
Failed("CMake is not fun, so it is broken and should be fixed."); Failed("CMake is not fun, so it is broken and should be fixed.");
#else #else
Passed("CMAKE_IS_FUN is defined."); Passed("CMAKE_IS_FUN is defined.");
#endif #endif
// ----------------------------------------------------------------------
// Test SET, VARIABLE_REQUIRES
#ifdef SHOULD_NOT_BE_DEFINED #ifdef SHOULD_NOT_BE_DEFINED
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined."); Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED is defined.");
#else #else
@ -106,6 +121,42 @@ int main()
Passed("SHOULD_BE_DEFINED is defined."); Passed("SHOULD_BE_DEFINED is defined.");
#endif #endif
#ifndef ONE_VAR
Failed("cmakedefine is broken, ONE_VAR is not defined.");
#else
Passed("ONE_VAR is defined.");
#endif
#ifndef ONE_VAR_IS_DEFINED
Failed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
"ONE_VAR_IS_DEFINED is not defined.");
#else
Passed("ONE_VAR_IS_DEFINED is defined.");
#endif
#ifdef ZERO_VAR
Failed("cmakedefine is broken, ZERO_VAR is defined.");
#else
Passed("ZERO_VAR is not defined.");
#endif
#ifndef STRING_VAR
Failed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
#else
if(strcmp(STRING_VAR, "CMake is great") != 0)
{
Failed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
STRING_VAR);
}
else
{
Passed("STRING_VAR == ", STRING_VAR);
}
#endif
// ----------------------------------------------------------------------
// Test various IF/ELSE combinations
#ifdef SHOULD_NOT_BE_DEFINED_AND #ifdef SHOULD_NOT_BE_DEFINED_AND
Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined."); Failed("IF or SET is broken, SHOULD_NOT_BE_DEFINED_AND is defined.");
#else #else
@ -142,38 +193,8 @@ int main()
Passed("SHOULD_BE_DEFINED_MATCHES is defined."); Passed("SHOULD_BE_DEFINED_MATCHES is defined.");
#endif #endif
#ifndef ONE_VAR // ----------------------------------------------------------------------
Failed("cmakedefine is broken, ONE_VAR is not defined."); // Test FOREACH
#else
Passed("ONE_VAR is defined.");
#endif
#ifndef ONE_VAR_IS_DEFINED
Failed("cmakedefine, SET or VARIABLE_REQUIRES is broken, "
"ONE_VAR_IS_DEFINED is not defined.");
#else
Passed("ONE_VAR_IS_DEFINED is defined.");
#endif
#ifdef ZERO_VAR
Failed("cmakedefine is broken, ZERO_VAR is defined.");
#else
Passed("ZERO_VAR is not defined.");
#endif
#ifndef STRING_VAR
Failed("the CONFIGURE_FILE command is broken, STRING_VAR is not defined.");
#else
if(strcmp(STRING_VAR, "CMake is great") != 0)
{
Failed("the SET or CONFIGURE_FILE command is broken. STRING_VAR == ",
STRING_VAR);
}
else
{
Passed("STRING_VAR == ", STRING_VAR);
}
#endif
#ifndef FOREACH_VAR1 #ifndef FOREACH_VAR1
Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, " Failed("the FOREACH, SET or CONFIGURE_FILE command is broken, "
@ -205,6 +226,9 @@ int main()
} }
#endif #endif
// ----------------------------------------------------------------------
// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
#ifndef FILENAME_VAR_PATH_NAME #ifndef FILENAME_VAR_PATH_NAME
Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, " Failed("the FIND_FILE or GET_FILENAME_COMPONENT command is broken, "
"FILENAME_VAR_PATH_NAME is not defined."); "FILENAME_VAR_PATH_NAME is not defined.");
@ -280,6 +304,9 @@ int main()
} }
#endif #endif
// ----------------------------------------------------------------------
// Test LOAD_CACHE
#ifndef CACHE_TEST_VAR1 #ifndef CACHE_TEST_VAR1
Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, " Failed("the LOAD_CACHE or CONFIGURE_FILE command is broken, "
"CACHE_TEST_VAR1 is not defined."); "CACHE_TEST_VAR1 is not defined.");
@ -325,22 +352,26 @@ int main()
} }
#endif #endif
// ----------------------------------------------------------------------
// A post-build custom-command has been attached to the lib (see Library/). // A post-build custom-command has been attached to the lib (see Library/).
// It run ${CREATE_FILE_EXE} which will create the file // It runs ${CREATE_FILE_EXE} which will create a file.
// ${Complex_BINARY_DIR}/Library/postbuild.txt.
TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt"); TestAndRemoveFile(BINARY_DIR "/Library/postbuild.txt");
// ----------------------------------------------------------------------
// A custom target has been created (see Library/). // A custom target has been created (see Library/).
// It run ${CREATE_FILE_EXE} which will create the file // It runs ${CREATE_FILE_EXE} which will create a file.
// ${Complex_BINARY_DIR}/Library/custom_target1.txt.
TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt"); TestAndRemoveFile(BINARY_DIR "/Library/custom_target1.txt");
// ----------------------------------------------------------------------
// A directory has been created. // A directory has been created.
TestDir(BINARY_DIR "/make_dir"); TestDir(BINARY_DIR "/make_dir");
// ----------------------------------------------------------------------
// Summary
std::cout << "Passed: " << passed << "\n"; std::cout << "Passed: " << passed << "\n";
if(failed) if(failed)
{ {

View File

@ -1,25 +1,30 @@
AUX_SOURCE_DIRECTORY(ExtraSources LibrarySources)
# SOURCE_FILES_REMOVE is used for Coverage
SOURCE_FILES(LibrarySources file2 GENERATED nonexisting_file)
SOURCE_FILES_REMOVE(LibrarySources GENERATED nonexisting_file)
ADD_LIBRARY(CMakeTestLibrary LibrarySources)
SOURCE_FILES(SharedLibrarySources sharedFile)
ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)
# #
# Small utility used to create file # Small utility used to create file
# UTILITY_SOURCE is used for coverage and for getting the exact name
# of the executable.
# #
UTILITY_SOURCE(CREATE_FILE_EXE create_file "." create_file.cxx) UTILITY_SOURCE(CREATE_FILE_EXE create_file "." create_file.cxx)
ADD_EXECUTABLE(create_file create_file.cxx) ADD_EXECUTABLE(create_file create_file.cxx)
#
# Create static library
# SOURCE_FILES_REMOVE is used for Coverage
#
AUX_SOURCE_DIRECTORY(ExtraSources LibrarySources)
SOURCE_FILES(LibrarySources file2 create_file.cxx GENERATED nonexisting_file)
SOURCE_FILES_REMOVE(LibrarySources create_file.cxx GENERATED nonexisting_file)
ADD_LIBRARY(CMakeTestLibrary LibrarySources)
#
# Create shared library
#
SOURCE_FILES(SharedLibrarySources sharedFile)
ADD_LIBRARY(CMakeTestLibraryShared SHARED SharedLibrarySources)
# #
# Attach a post-build custom-command to the lib. # Attach a post-build custom-command to the lib.
# It run ${CREATE_FILE_EXE} which will create the file # It runs ${CREATE_FILE_EXE} which will create a file.
# ${Complex_BINARY_DIR}/Library/postbuild.txt. # The 'complex' executable will then test if this file exists and remove it.
# The 'complex' executable will then test if this file exists,
# and remove it.
# #
ADD_DEPENDENCIES(CMakeTestLibraryShared create_file) ADD_DEPENDENCIES(CMakeTestLibraryShared create_file)
@ -29,11 +34,10 @@ ADD_CUSTOM_COMMAND(SOURCE CMakeTestLibraryShared
TARGET CMakeTestLibraryShared) TARGET CMakeTestLibraryShared)
# #
# Add custom target # Add a custom target.
# It run ${CREATE_FILE_EXE} which will create the file # It runs ${CREATE_FILE_EXE} which will create the file
# ${Complex_BINARY_DIR}/Library/custom_target1.txt. # It runs ${CREATE_FILE_EXE} which will create a file.
# The 'complex' executable will then test if this file exists, # The 'complex' executable will then test if this file exists and remove it.
# and remove it.
# #
ADD_CUSTOM_TARGET(custom_target1 ADD_CUSTOM_TARGET(custom_target1
ALL ALL
@ -42,6 +46,12 @@ ADD_CUSTOM_TARGET(custom_target1
ADD_DEPENDENCIES(custom_target1 create_file) ADD_DEPENDENCIES(custom_target1 create_file)
# More coverage #
# Extra coverage
#
ABSTRACT_FILES(
ExtraSources/file1.cxx
)
INSTALL_FILES(/tmp .h ${Complex_BINARY_DIR}/cmTestConfigure.h)
SOURCE_GROUP(A_GROUP ".cxx")

View File

@ -1,3 +1,6 @@
#
# Test SET
#
SET (ZERO_VAR 0) SET (ZERO_VAR 0)
IF(ZERO_VAR) IF(ZERO_VAR)
@ -7,12 +10,18 @@ ELSE(ZERO_VAR)
ENDIF(ZERO_VAR) ENDIF(ZERO_VAR)
SET(ONE_VAR 1) SET(ONE_VAR 1)
SET(ONE_VAR2 1)
SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
#
# Test VARIABLE_REQUIRES
#
VARIABLE_REQUIRES(ONE_VAR VARIABLE_REQUIRES(ONE_VAR
ONE_VAR_IS_DEFINED ONE_VAR) ONE_VAR_IS_DEFINED ONE_VAR)
SET (ONE_VAR2 1) #
# Test various IF/ELSE combinations
#
IF(ONE_VAR AND ONE_VAR2) IF(ONE_VAR AND ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND) ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_AND)
ELSE(ONE_VAR AND ONE_VAR2) ELSE(ONE_VAR AND ONE_VAR2)
@ -25,32 +34,29 @@ ELSE(ZERO_VAR OR ONE_VAR2)
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR) ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_OR)
ENDIF(ZERO_VAR OR ONE_VAR2) ENDIF(ZERO_VAR OR ONE_VAR2)
SET(STRING_VAR "CMake is great" CACHE STRING "test a cache variable")
IF(STRING_VAR MATCHES "^CMake") IF(STRING_VAR MATCHES "^CMake")
ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES) ADD_DEFINITIONS(-DSHOULD_BE_DEFINED_MATCHES)
ELSE(STRING_VAR MATCHES "^CMake") ELSE(STRING_VAR MATCHES "^CMake")
ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES) ADD_DEFINITIONS(-DSHOULD_NOT_BE_DEFINED_MATCHES)
ENDIF(STRING_VAR MATCHES "^CMake") ENDIF(STRING_VAR MATCHES "^CMake")
#
# Test FOREACH
#
FOREACH (INDEX 1 2) FOREACH (INDEX 1 2)
SET(FOREACH_VAR${INDEX} "VALUE${INDEX}") SET(FOREACH_VAR${INDEX} "VALUE${INDEX}")
ENDFOREACH(INDEX) ENDFOREACH(INDEX)
#
# Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
#
FIND_FILE(FILENAME_VAR "VarTests.cmake" ${Complex_SOURCE_DIR}) FIND_FILE(FILENAME_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
GET_FILENAME_COMPONENT(FILENAME_VAR_PATH ${FILENAME_VAR} PATH) GET_FILENAME_COMPONENT(FILENAME_VAR_PATH ${FILENAME_VAR} PATH)
GET_FILENAME_COMPONENT(FILENAME_VAR_PATH_NAME ${FILENAME_VAR_PATH} NAME) GET_FILENAME_COMPONENT(FILENAME_VAR_PATH_NAME ${FILENAME_VAR_PATH} NAME)
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME ${FILENAME_VAR} NAME) GET_FILENAME_COMPONENT(FILENAME_VAR_NAME ${FILENAME_VAR} NAME)
GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT) GET_FILENAME_COMPONENT(FILENAME_VAR_EXT ${FILENAME_VAR} EXT)
GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE) GET_FILENAME_COMPONENT(FILENAME_VAR_NAME_WE ${FILENAME_VAR} NAME_WE CACHE)
FIND_PATH(PATH_VAR "VarTests.cmake" ${Complex_SOURCE_DIR}) FIND_PATH(PATH_VAR "VarTests.cmake" ${Complex_SOURCE_DIR})
GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME) GET_FILENAME_COMPONENT(PATH_VAR_NAME ${PATH_VAR} NAME)
# Coverage only
BUILD_COMMAND(BUILD_COMMAND_VAR ${CMAKE_MAKE_PROGRAM})
BUILD_NAME(BUILD_NAME_VAR)
SITE_NAME(SITE_NAME_VAR)

View File

@ -1,12 +1,18 @@
// Test SET, VARIABLE_REQUIRES
#cmakedefine ONE_VAR #cmakedefine ONE_VAR
#cmakedefine ONE_VAR_IS_DEFINED #cmakedefine ONE_VAR_IS_DEFINED
#cmakedefine ZERO_VAR #cmakedefine ZERO_VAR
#define STRING_VAR "${STRING_VAR}" #define STRING_VAR "${STRING_VAR}"
// Test FOREACH
#define FOREACH_VAR1 "${FOREACH_VAR1}" #define FOREACH_VAR1 "${FOREACH_VAR1}"
#define FOREACH_VAR2 "${FOREACH_VAR2}" #define FOREACH_VAR2 "${FOREACH_VAR2}"
// Test FIND_FILE, FIND_PATH and various GET_FILENAME_COMPONENT combinations
#define FILENAME_VAR_PATH_NAME "${FILENAME_VAR_PATH_NAME}" #define FILENAME_VAR_PATH_NAME "${FILENAME_VAR_PATH_NAME}"
#define FILENAME_VAR_NAME "${FILENAME_VAR_NAME}" #define FILENAME_VAR_NAME "${FILENAME_VAR_NAME}"
#define FILENAME_VAR_EXT "${FILENAME_VAR_EXT}" #define FILENAME_VAR_EXT "${FILENAME_VAR_EXT}"
@ -14,20 +20,18 @@
#define PATH_VAR_NAME "${PATH_VAR_NAME}" #define PATH_VAR_NAME "${PATH_VAR_NAME}"
#cmakedefine CMAKE_NO_STD_NAMESPACE // Test LOAD_CACHE
#cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
#cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
#define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}" #define CACHE_TEST_VAR1 "${CACHE_TEST_VAR1}"
#define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}" #define CACHE_TEST_VAR2 "${CACHE_TEST_VAR2}"
#define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}" #define CACHE_TEST_VAR3 "${CACHE_TEST_VAR3}"
// Test internal CMake vars from C++ flags
#cmakedefine CMAKE_NO_STD_NAMESPACE
#cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
#cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
// Needed to check for files // Needed to check for files
#define BINARY_DIR "${Complex_BINARY_DIR}" #define BINARY_DIR "${Complex_BINARY_DIR}"
// Coverage only
#define BUILD_COMMAND_VAR "${BUILD_COMMAND_VAR}"
#define BUILD_NAME_VAR "${BUILD_NAME_VAR}"
#define SITE_NAME_VAR "${SITE_NAME_VAR}"

View File

@ -0,0 +1,56 @@
#
# Testing
#
PROJECT (Testing)
#
# Lib and exe path
#
SET (LIBRARY_OUTPUT_PATH
${Testing_BINARY_DIR}/bin/ CACHE PATH
"Single output directory for building all libraries.")
SET (EXECUTABLE_OUTPUT_PATH
${Testing_BINARY_DIR}/bin/ CACHE PATH
"Single output directory for building all executables.")
#
# Where will executable tests be written ?
#
IF (EXECUTABLE_OUTPUT_PATH)
SET (CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
ELSE (EXECUTABLE_OUTPUT_PATH)
SET (CXX_TEST_PATH .)
ENDIF (EXECUTABLE_OUTPUT_PATH)
#
# Link to CMake lib
#
FIND_LIBRARY(CMAKE_LIB
CMakeLib
${Testing_BINARY_DIR}/../../Source
${Testing_BINARY_DIR}/../../Source/Debug
${Testing_BINARY_DIR}/../../Source/Release
${Testing_BINARY_DIR}/../../Source/MinSizeRel
${Testing_BINARY_DIR}/../../Source/RelWithDebInfo)
LINK_LIBRARIES(${CMAKE_LIB})
#
# Extra coverage
#
BUILD_COMMAND(BUILD_COMMAND_VAR ${CMAKE_MAKE_PROGRAM})
BUILD_NAME(BUILD_NAME_VAR)
SITE_NAME(SITE_NAME_VAR)
#
# Enable testing
#
ENABLE_TESTING()
#
# Add test
#
ADD_EXECUTABLE(testing testing.cxx)
ADD_TEST(testing ${Testing_BINARY_DIR}/bin/testing)

View File

@ -0,0 +1,4 @@
int main ()
{
return 0;
}

View File

@ -0,0 +1,49 @@
#
# Wrapping
#
PROJECT (Wrapping)
#
# Lib and exe path
#
SET (LIBRARY_OUTPUT_PATH
${Wrapping_BINARY_DIR}/bin/ CACHE PATH
"Single output directory for building all libraries.")
SET (EXECUTABLE_OUTPUT_PATH
${Wrapping_BINARY_DIR}/bin/ CACHE PATH
"Single output directory for building all executables.")
#
# Where will executable tests be written ?
#
IF (EXECUTABLE_OUTPUT_PATH)
SET (CXX_TEST_PATH ${EXECUTABLE_OUTPUT_PATH})
ELSE (EXECUTABLE_OUTPUT_PATH)
SET (CXX_TEST_PATH .)
ENDIF (EXECUTABLE_OUTPUT_PATH)
#
# Link to CMake lib
#
FIND_LIBRARY(CMAKE_LIB
CMakeLib
${Wrapping_BINARY_DIR}/../../Source
${Wrapping_BINARY_DIR}/../../Source/Debug
${Wrapping_BINARY_DIR}/../../Source/Release
${Wrapping_BINARY_DIR}/../../Source/MinSizeRel
${Wrapping_BINARY_DIR}/../../Source/RelWithDebInfo)
LINK_LIBRARIES(${CMAKE_LIB})
#
# Test Cable
#
CABLE_CLASS_SET(Float float)
CABLE_CLASS_SET(Mesh "itk::Mesh<$Float>")
#
# Add exe
#
ADD_EXECUTABLE(wrapping wrapping.cxx)

View File

@ -0,0 +1,4 @@
int main ()
{
return 0;
}