CMake/Tests/ComplexOneConfig/CMakeLists.txt

214 lines
5.6 KiB
CMake
Raw Normal View History

#
2002-01-19 03:21:43 +03:00
# A more complex test case
#
2001-08-23 21:57:45 +04:00
PROJECT (Complex)
2002-08-13 23:47:19 +04:00
#
# Define a macro
#
MACRO(ASSERT value msg)
IF (NOT ${value})
MESSAGE ("Assertion failure:" ${msg} )
ENDIF (NOT ${value})
ENDMACRO(ASSERT)
# invoke the macro
ASSERT(Complex_BINARY_DIR "The PROJECT command is broken")
#
# Use the ansi CXX compile flag for building cmake
#
2001-08-29 00:06:52 +04:00
IF (CMAKE_ANSI_CXXFLAGS)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}")
ENDIF (CMAKE_ANSI_CXXFLAGS)
2001-08-27 18:11:48 +04:00
2002-06-18 16:54:07 +04:00
IF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
IF(NOT CMAKE_COMPILER_IS_GNUCXX)
2002-06-19 15:28:30 +04:00
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ")
2002-06-18 16:54:07 +04:00
ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX)
ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
2001-08-23 21:57:45 +04:00
ADD_DEFINITIONS(-DCMAKE_IS_FUN)
2002-04-30 22:01:07 +04:00
SET(TEST_SEP "a b c")
SEPARATE_ARGUMENTS(TEST_SEP)
#
# Include vars from a file and from a cache
#
2002-01-19 04:32:06 +03:00
IF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
INCLUDE(${Complex_SOURCE_DIR}/VarTests.cmake)
ENDIF (EXISTS ${Complex_SOURCE_DIR}/VarTests.cmake)
2002-05-23 21:27:21 +04:00
INCLUDE(fileshouldnotbehere OPTIONAL)
LOAD_CACHE(${Complex_SOURCE_DIR}/Cache
2002-01-20 08:12:27 +03:00
EXCLUDE
CACHE_TEST_VAR_EXCLUDED
INCLUDE_INTERNALS
CACHE_TEST_VAR_INTERNAL)
2002-01-19 03:21:43 +03:00
#
# Specify include and lib dirs
2002-01-20 08:12:27 +03:00
# (BEFORE is for coverage)
#
2001-08-23 21:57:45 +04:00
INCLUDE_DIRECTORIES(
${Complex_SOURCE_DIR}/Library
${Complex_SOURCE_DIR}/../../Source
2001-08-23 21:57:45 +04:00
)
2002-01-20 08:12:27 +03:00
INCLUDE_DIRECTORIES(BEFORE
${Complex_BINARY_DIR}
)
2002-01-20 09:58:57 +03:00
INCLUDE_REGULAR_EXPRESSION("^(cmTest|file|sharedFile).*$" ".*")
2001-08-23 21:57:45 +04:00
LINK_DIRECTORIES(
${Complex_BINARY_DIR}/Library
2001-08-23 21:57:45 +04:00
)
#
# Lib and exe path
#
SET (LIBRARY_OUTPUT_PATH
${Complex_BINARY_DIR}/bin/ CACHE PATH
"Single output directory for building all libraries.")
SET (EXECUTABLE_OUTPUT_PATH
${Complex_BINARY_DIR}/bin/ CACHE PATH
"Single output directory for building all executables.")
2002-04-18 20:02:00 +04:00
MESSAGE (Test " " escape " " semi-colon " " \; \;)
2002-01-18 20:03:32 +03:00
#
2002-01-19 04:32:06 +03:00
# Exec program (TODO: test a result)
2002-01-18 20:03:32 +03:00
# Increase coverage.
#
2002-03-29 23:02:18 +03:00
MESSAGE("\nIgnore this message")
2002-01-19 04:32:06 +03:00
OPTION(NO_EXEC_PROGRAM "Do not test EXEC_PROGRAM" 0)
IF (NOT NO_EXEC_PROGRAM)
2002-09-28 01:16:03 +04:00
EXEC_PROGRAM(${CMAKE_COMMAND} ARGS -E echo NO_EXEC_PROGRAM "${Complex_BINARY_DIR}")
2002-01-19 04:32:06 +03:00
ELSE (NOT NO_EXEC_PROGRAM)
MESSAGE("Set this option ON")
ENDIF (NOT NO_EXEC_PROGRAM)
MARK_AS_ADVANCED(NO_EXEC_PROGRAM)
MARK_AS_ADVANCED(CLEAR NO_EXEC_PROGRAM)
2002-01-19 03:21:43 +03:00
#
# Create directory.
# The 'complex' executable will then test if this dir exists,
# sadly it won't be able to remove it.
#
MAKE_DIRECTORY("${Complex_BINARY_DIR}/make_dir")
2002-03-29 23:02:18 +03:00
#
# Test FIND_LIBARY
# Create a dummy empty lib
#
2002-03-29 23:41:10 +03:00
CONFIGURE_FILE(
${Complex_SOURCE_DIR}/Library/dummy
${Complex_BINARY_DIR}/Library/dummylib.lib
COPYONLY IMMEDIATE)
FOREACH (ext "${CMAKE_SHLIB_SUFFIX};.so;.a;.sl")
2002-03-29 23:02:18 +03:00
CONFIGURE_FILE(
${Complex_SOURCE_DIR}/Library/dummy
2002-03-29 23:41:10 +03:00
${Complex_BINARY_DIR}/Library/libdummylib${ext}
2002-03-29 23:02:18 +03:00
COPYONLY IMMEDIATE)
ENDFOREACH (ext)
FIND_LIBRARY(FIND_DUMMY_LIB
dummylib
PATHS
2002-05-23 21:23:35 +04:00
${Complex_BINARY_DIR}/Library DOC "find dummy lib")
FIND_LIBRARY(FIND_DUMMY_LIB
NAMES dummylib dummylib2
PATHS
${Complex_BINARY_DIR}/Library DOC "find dummy lib")
2002-03-29 23:02:18 +03:00
#
# Test SET_SOURCE_FILES_PROPERTIES
#
SET_SOURCE_FILES_PROPERTIES(nonexisting_file2
GENERATED
ABSTRACT
WRAP_EXCLUDE
COMPILE_FLAGS "-foo -bar")
GET_SOURCE_FILE_PROPERTY(FILE_HAS_ABSTRACT nonexisting_file2 ABSTRACT)
GET_SOURCE_FILE_PROPERTY(FILE_HAS_WRAP_EXCLUDE nonexisting_file2 WRAP_EXCLUDE)
GET_SOURCE_FILE_PROPERTY(FILE_COMPILE_FLAGS nonexisting_file2 COMPILE_FLAGS)
SET_SOURCE_FILES_PROPERTIES(nonexisting_file3 PROPERTIES
GENERATED 1
ABSTRACT 1
WRAP_EXCLUDE 1
COMPILE_FLAGS "-foo -bar")
GET_SOURCE_FILE_PROPERTY(FILE_HAS_ABSTRACT nonexisting_file3 ABSTRACT)
GET_SOURCE_FILE_PROPERTY(FILE_HAS_WRAP_EXCLUDE nonexisting_file3 WRAP_EXCLUDE)
GET_SOURCE_FILE_PROPERTY(FILE_COMPILE_FLAGS nonexisting_file3 COMPILE_FLAGS)
#
# Test registry (win32)
# Create a file, put its path in a registry key, try to find the file in that
# path using that registry key, then remove the file and the key
#
IF (WIN32)
IF (NOT UNIX)
SET(dir "${Complex_BINARY_DIR}/registry_dir")
SET(file "registry_test_dummy")
SET(hkey "HKEY_CURRENT_USER\\Software\\Kitware\\CMake\\Tests\\Complex;registry_test")
CONFIGURE_FILE(
${Complex_SOURCE_DIR}/Library/dummy
"${dir}/${file}"
COPYONLY IMMEDIATE)
2002-06-03 21:08:52 +04:00
EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E write_regv \"${hkey}\" \"${dir}\"")
FIND_PATH(REGISTRY_TEST_PATH
${file}
2002-05-23 21:23:35 +04:00
"[${hkey}]" DOC "Registry_Test_Path")
2002-06-03 21:08:52 +04:00
EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E delete_regv \"${hkey}\"")
EXEC_PROGRAM(${CMAKE_COMMAND} ARGS "-E remove \"${dir}/${file}\"")
ENDIF (NOT UNIX)
ENDIF (WIN32)
2002-04-22 19:51:26 +04:00
#
# Test a set and a remove
#
SET(REMOVE_STRING a b c d e f)
SET(removeVar1 c e)
REMOVE(REMOVE_STRING ${removeVar1} f)
#
# Test an IF inside a FOREACH.
#
FOREACH(x "a")
2002-07-17 18:48:39 +04:00
IF(${x} MATCHES "a")
# Should always execute.
SET(IF_INSIDE_FOREACH_THEN_EXECUTED 1)
2002-07-17 18:48:39 +04:00
ELSE(${x} MATCHES "a")
# Should never execute.
SET(IF_INSIDE_FOREACH_ELSE_EXECUTED 1)
2002-07-17 18:48:39 +04:00
ENDIF(${x} MATCHES "a")
ENDFOREACH(x)
2002-03-29 23:02:18 +03:00
#
# Configure file
# (plug vars to #define so that they can be tested)
#
CONFIGURE_FILE(
${Complex_SOURCE_DIR}/cmTestConfigure.h.in
${Complex_BINARY_DIR}/cmTestConfigure.h)
SET(STRING_WITH_QUOTES "\"hello world\"")
# test CONFIGURE_FILE with ESCAPE_QUOTES on
CONFIGURE_FILE(
${Complex_SOURCE_DIR}/cmTestConfigureEscape.h.in
${Complex_BINARY_DIR}/cmTestConfigureEscape.h ESCAPE_QUOTES)
2002-03-29 23:02:18 +03:00
#
# Create the libs and the main exe
#
SUBDIRS(Library Executable)
SUBDIR_DEPENDS(Executable Library)