ENH: Added explicit name for option to test CMakeLib. Added option to disable testing of CMakeLib if system utility libraries are used until linking made easier.

This commit is contained in:
Brad King 2006-10-19 14:45:41 -04:00
parent 93ce08e373
commit b646183f44
12 changed files with 60 additions and 30 deletions

View File

@ -4,6 +4,15 @@
SET(CMAKE_BACKWARDS_COMPATIBILITY 1.4) SET(CMAKE_BACKWARDS_COMPATIBILITY 1.4)
PROJECT (Complex) PROJECT (Complex)
# Choose whether to test CMakeLib.
SET(COMPLEX_TEST_CMAKELIB 1)
IF(CMAKE_TEST_DIFFERENT_GENERATOR)
SET(COMPLEX_TEST_CMAKELIB 0)
ENDIF(CMAKE_TEST_DIFFERENT_GENERATOR)
IF(CMAKE_TEST_SYSTEM_LIBRARIES)
SET(COMPLEX_TEST_CMAKELIB 0)
ENDIF(CMAKE_TEST_SYSTEM_LIBRARIES)
# #
# Define a macro # Define a macro
# #

View File

@ -6,14 +6,14 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTEST_CXX_FLAGS")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTEST_C_FLAGS") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTEST_C_FLAGS")
SET(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}") SET(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}")
IF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) IF(COMPLEX_TEST_CMAKELIB)
# Link to CMake lib # Link to CMake lib
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source)
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source/kwsys) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source/kwsys)
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmexpat) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmexpat)
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmzlib) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmzlib)
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmtar) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmtar)
ENDIF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) ENDIF(COMPLEX_TEST_CMAKELIB)
# Use LINK_LIBRARIES instead of TARGET_LINK_LIBRARIES to # Use LINK_LIBRARIES instead of TARGET_LINK_LIBRARIES to
SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared) SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared)
@ -23,9 +23,9 @@ ADD_EXECUTABLE(A A.cxx A.hh A.h A.txt)
ADD_EXECUTABLE(complex complex testcflags.c ) ADD_EXECUTABLE(complex complex testcflags.c )
# Sub1/NameConflictTest.c Sub2/NameConflictTest.c) # Sub1/NameConflictTest.c Sub2/NameConflictTest.c)
ADD_EXECUTABLE(complex.file complex.file.cxx) ADD_EXECUTABLE(complex.file complex.file.cxx)
IF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) IF(COMPLEX_TEST_CMAKELIB)
TARGET_LINK_LIBRARIES(complex CMakeLib cmsys cmexpat cmzlib cmtar) TARGET_LINK_LIBRARIES(complex CMakeLib cmsys cmexpat cmzlib cmtar)
ENDIF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) ENDIF(COMPLEX_TEST_CMAKELIB)
IF (UNIX) IF (UNIX)
TARGET_LINK_LIBRARIES(complex ${CMAKE_DL_LIBS}) TARGET_LINK_LIBRARIES(complex ${CMAKE_DL_LIBS})

View File

@ -8,7 +8,7 @@
extern "C" { extern "C" {
#include "testConly.h" #include "testConly.h"
} }
#ifndef CMAKE_TEST_DIFFERENT_GENERATOR #ifdef CMAKE_TEST_CMAKELIB
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmDynamicLoader.h" #include "cmDynamicLoader.h"
@ -64,7 +64,7 @@ void cmPassed(const char* Message, const char* m2="")
This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work
#endif #endif
#ifndef CMAKE_TEST_DIFFERENT_GENERATOR #ifdef CMAKE_TEST_CMAKELIB
// Here is a stupid function that tries to use std::string methods // Here is a stupid function that tries to use std::string methods
// so that the dec cxx compiler will instantiate the stuff that // so that the dec cxx compiler will instantiate the stuff that
// we are using from the CMakeLib library.... // we are using from the CMakeLib library....
@ -327,7 +327,7 @@ int main()
#endif #endif
std::string exe = lib; std::string exe = lib;
#ifndef CMAKE_TEST_DIFFERENT_GENERATOR #ifdef CMAKE_TEST_CMAKELIB
// Test a single character executable to test a: in makefiles // Test a single character executable to test a: in makefiles
exe += "A"; exe += "A";
exe += cmSystemTools::GetExecutableExtension(); exe += cmSystemTools::GetExecutableExtension();
@ -1059,7 +1059,7 @@ int main()
} }
#endif #endif
#ifndef CMAKE_TEST_DIFFERENT_GENERATOR #ifdef CMAKE_TEST_CMAKELIB
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Some pre-build/pre-link/post-build custom-commands have been // Some pre-build/pre-link/post-build custom-commands have been
// attached to the lib (see Library/). // attached to the lib (see Library/).
@ -1257,7 +1257,7 @@ int main()
cmPassed("CMake SET CACHE FORCE"); cmPassed("CMake SET CACHE FORCE");
#endif #endif
#ifndef CMAKE_TEST_DIFFERENT_GENERATOR #ifdef CMAKE_TEST_CMAKELIB
// first run with shouldFail = true, this will // first run with shouldFail = true, this will
// run with A B C as set by the CMakeList.txt file. // run with A B C as set by the CMakeList.txt file.
if(!TestLibraryOrder(true)) if(!TestLibraryOrder(true))

View File

@ -4,7 +4,8 @@
#cmakedefine ONE_VAR_IS_DEFINED #cmakedefine ONE_VAR_IS_DEFINED
#cmakedefine ZERO_VAR #cmakedefine ZERO_VAR
#cmakedefine CMAKE_TEST_DIFFERENT_GENERATOR #cmakedefine COMPLEX_TEST_CMAKELIB
#define STRING_VAR "${STRING_VAR}" #define STRING_VAR "${STRING_VAR}"
// Test FOREACH // Test FOREACH

View File

@ -4,6 +4,15 @@
SET(CMAKE_BACKWARDS_COMPATIBILITY 1.4) SET(CMAKE_BACKWARDS_COMPATIBILITY 1.4)
PROJECT (Complex) PROJECT (Complex)
# Choose whether to test CMakeLib.
SET(COMPLEX_TEST_CMAKELIB 1)
IF(CMAKE_TEST_DIFFERENT_GENERATOR)
SET(COMPLEX_TEST_CMAKELIB 0)
ENDIF(CMAKE_TEST_DIFFERENT_GENERATOR)
IF(CMAKE_TEST_SYSTEM_LIBRARIES)
SET(COMPLEX_TEST_CMAKELIB 0)
ENDIF(CMAKE_TEST_SYSTEM_LIBRARIES)
# #
# Define a macro # Define a macro
# #

View File

@ -6,14 +6,14 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTEST_CXX_FLAGS")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTEST_C_FLAGS") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTEST_C_FLAGS")
SET(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}") SET(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}")
IF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) IF(COMPLEX_TEST_CMAKELIB)
# Link to CMake lib # Link to CMake lib
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source)
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source/kwsys) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source/kwsys)
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmexpat) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmexpat)
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmzlib) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmzlib)
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmtar) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmtar)
ENDIF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) ENDIF(COMPLEX_TEST_CMAKELIB)
# Use LINK_LIBRARIES instead of TARGET_LINK_LIBRARIES to # Use LINK_LIBRARIES instead of TARGET_LINK_LIBRARIES to
SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared) SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared)
@ -23,9 +23,9 @@ ADD_EXECUTABLE(A A.cxx A.hh A.h A.txt)
ADD_EXECUTABLE(complex complex testcflags.c ) ADD_EXECUTABLE(complex complex testcflags.c )
# Sub1/NameConflictTest.c Sub2/NameConflictTest.c) # Sub1/NameConflictTest.c Sub2/NameConflictTest.c)
ADD_EXECUTABLE(complex.file complex.file.cxx) ADD_EXECUTABLE(complex.file complex.file.cxx)
IF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) IF(COMPLEX_TEST_CMAKELIB)
TARGET_LINK_LIBRARIES(complex CMakeLib cmsys cmexpat cmzlib cmtar) TARGET_LINK_LIBRARIES(complex CMakeLib cmsys cmexpat cmzlib cmtar)
ENDIF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) ENDIF(COMPLEX_TEST_CMAKELIB)
IF (UNIX) IF (UNIX)
TARGET_LINK_LIBRARIES(complex ${CMAKE_DL_LIBS}) TARGET_LINK_LIBRARIES(complex ${CMAKE_DL_LIBS})

View File

@ -8,7 +8,7 @@
extern "C" { extern "C" {
#include "testConly.h" #include "testConly.h"
} }
#ifndef CMAKE_TEST_DIFFERENT_GENERATOR #ifdef CMAKE_TEST_CMAKELIB
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmDynamicLoader.h" #include "cmDynamicLoader.h"
@ -64,7 +64,7 @@ void cmPassed(const char* Message, const char* m2="")
This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work
#endif #endif
#ifndef CMAKE_TEST_DIFFERENT_GENERATOR #ifdef CMAKE_TEST_CMAKELIB
// Here is a stupid function that tries to use std::string methods // Here is a stupid function that tries to use std::string methods
// so that the dec cxx compiler will instantiate the stuff that // so that the dec cxx compiler will instantiate the stuff that
// we are using from the CMakeLib library.... // we are using from the CMakeLib library....
@ -327,7 +327,7 @@ int main()
#endif #endif
std::string exe = lib; std::string exe = lib;
#ifndef CMAKE_TEST_DIFFERENT_GENERATOR #ifdef CMAKE_TEST_CMAKELIB
// Test a single character executable to test a: in makefiles // Test a single character executable to test a: in makefiles
exe += "A"; exe += "A";
exe += cmSystemTools::GetExecutableExtension(); exe += cmSystemTools::GetExecutableExtension();
@ -1059,7 +1059,7 @@ int main()
} }
#endif #endif
#ifndef CMAKE_TEST_DIFFERENT_GENERATOR #ifdef CMAKE_TEST_CMAKELIB
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Some pre-build/pre-link/post-build custom-commands have been // Some pre-build/pre-link/post-build custom-commands have been
// attached to the lib (see Library/). // attached to the lib (see Library/).
@ -1257,7 +1257,7 @@ int main()
cmPassed("CMake SET CACHE FORCE"); cmPassed("CMake SET CACHE FORCE");
#endif #endif
#ifndef CMAKE_TEST_DIFFERENT_GENERATOR #ifdef CMAKE_TEST_CMAKELIB
// first run with shouldFail = true, this will // first run with shouldFail = true, this will
// run with A B C as set by the CMakeList.txt file. // run with A B C as set by the CMakeList.txt file.
if(!TestLibraryOrder(true)) if(!TestLibraryOrder(true))

View File

@ -4,7 +4,8 @@
#cmakedefine ONE_VAR_IS_DEFINED #cmakedefine ONE_VAR_IS_DEFINED
#cmakedefine ZERO_VAR #cmakedefine ZERO_VAR
#cmakedefine CMAKE_TEST_DIFFERENT_GENERATOR #cmakedefine COMPLEX_TEST_CMAKELIB
#define STRING_VAR "${STRING_VAR}" #define STRING_VAR "${STRING_VAR}"
// Test FOREACH // Test FOREACH

View File

@ -4,6 +4,15 @@
SET(CMAKE_BACKWARDS_COMPATIBILITY 1.4) SET(CMAKE_BACKWARDS_COMPATIBILITY 1.4)
PROJECT (Complex) PROJECT (Complex)
# Choose whether to test CMakeLib.
SET(COMPLEX_TEST_CMAKELIB 1)
IF(CMAKE_TEST_DIFFERENT_GENERATOR)
SET(COMPLEX_TEST_CMAKELIB 0)
ENDIF(CMAKE_TEST_DIFFERENT_GENERATOR)
IF(CMAKE_TEST_SYSTEM_LIBRARIES)
SET(COMPLEX_TEST_CMAKELIB 0)
ENDIF(CMAKE_TEST_SYSTEM_LIBRARIES)
# #
# Define a macro # Define a macro
# #

View File

@ -6,14 +6,14 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTEST_CXX_FLAGS")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTEST_C_FLAGS") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DTEST_C_FLAGS")
SET(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}") SET(CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}")
IF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) IF(COMPLEX_TEST_CMAKELIB)
# Link to CMake lib # Link to CMake lib
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source)
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source/kwsys) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Source/kwsys)
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmexpat) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmexpat)
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmzlib) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmzlib)
LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmtar) LINK_DIRECTORIES(${Complex_BINARY_DIR}/../../Utilities/cmtar)
ENDIF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) ENDIF(COMPLEX_TEST_CMAKELIB)
# Use LINK_LIBRARIES instead of TARGET_LINK_LIBRARIES to # Use LINK_LIBRARIES instead of TARGET_LINK_LIBRARIES to
SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared) SET(COMPLEX_LIBS CMakeTestLibrary;CMakeTestLibraryShared;CMakeTestCLibraryShared)
@ -23,9 +23,9 @@ ADD_EXECUTABLE(A A.cxx A.hh A.h A.txt)
ADD_EXECUTABLE(complex complex testcflags.c ) ADD_EXECUTABLE(complex complex testcflags.c )
# Sub1/NameConflictTest.c Sub2/NameConflictTest.c) # Sub1/NameConflictTest.c Sub2/NameConflictTest.c)
ADD_EXECUTABLE(complex.file complex.file.cxx) ADD_EXECUTABLE(complex.file complex.file.cxx)
IF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) IF(COMPLEX_TEST_CMAKELIB)
TARGET_LINK_LIBRARIES(complex CMakeLib cmsys cmexpat cmzlib cmtar) TARGET_LINK_LIBRARIES(complex CMakeLib cmsys cmexpat cmzlib cmtar)
ENDIF(NOT CMAKE_TEST_DIFFERENT_GENERATOR) ENDIF(COMPLEX_TEST_CMAKELIB)
IF (UNIX) IF (UNIX)
TARGET_LINK_LIBRARIES(complex ${CMAKE_DL_LIBS}) TARGET_LINK_LIBRARIES(complex ${CMAKE_DL_LIBS})

View File

@ -8,7 +8,7 @@
extern "C" { extern "C" {
#include "testConly.h" #include "testConly.h"
} }
#ifndef CMAKE_TEST_DIFFERENT_GENERATOR #ifdef CMAKE_TEST_CMAKELIB
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
#include "cmSystemTools.h" #include "cmSystemTools.h"
#include "cmDynamicLoader.h" #include "cmDynamicLoader.h"
@ -64,7 +64,7 @@ void cmPassed(const char* Message, const char* m2="")
This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work
#endif #endif
#ifndef CMAKE_TEST_DIFFERENT_GENERATOR #ifdef CMAKE_TEST_CMAKELIB
// Here is a stupid function that tries to use std::string methods // Here is a stupid function that tries to use std::string methods
// so that the dec cxx compiler will instantiate the stuff that // so that the dec cxx compiler will instantiate the stuff that
// we are using from the CMakeLib library.... // we are using from the CMakeLib library....
@ -327,7 +327,7 @@ int main()
#endif #endif
std::string exe = lib; std::string exe = lib;
#ifndef CMAKE_TEST_DIFFERENT_GENERATOR #ifdef CMAKE_TEST_CMAKELIB
// Test a single character executable to test a: in makefiles // Test a single character executable to test a: in makefiles
exe += "A"; exe += "A";
exe += cmSystemTools::GetExecutableExtension(); exe += cmSystemTools::GetExecutableExtension();
@ -1059,7 +1059,7 @@ int main()
} }
#endif #endif
#ifndef CMAKE_TEST_DIFFERENT_GENERATOR #ifdef CMAKE_TEST_CMAKELIB
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Some pre-build/pre-link/post-build custom-commands have been // Some pre-build/pre-link/post-build custom-commands have been
// attached to the lib (see Library/). // attached to the lib (see Library/).
@ -1257,7 +1257,7 @@ int main()
cmPassed("CMake SET CACHE FORCE"); cmPassed("CMake SET CACHE FORCE");
#endif #endif
#ifndef CMAKE_TEST_DIFFERENT_GENERATOR #ifdef CMAKE_TEST_CMAKELIB
// first run with shouldFail = true, this will // first run with shouldFail = true, this will
// run with A B C as set by the CMakeList.txt file. // run with A B C as set by the CMakeList.txt file.
if(!TestLibraryOrder(true)) if(!TestLibraryOrder(true))

View File

@ -4,7 +4,8 @@
#cmakedefine ONE_VAR_IS_DEFINED #cmakedefine ONE_VAR_IS_DEFINED
#cmakedefine ZERO_VAR #cmakedefine ZERO_VAR
#cmakedefine CMAKE_TEST_DIFFERENT_GENERATOR #cmakedefine COMPLEX_TEST_CMAKELIB
#define STRING_VAR "${STRING_VAR}" #define STRING_VAR "${STRING_VAR}"
// Test FOREACH // Test FOREACH