ENH: add a test for external projects

This commit is contained in:
Bill Hoffman 2004-09-14 16:01:00 -04:00
parent 32fe8caaef
commit 013b66d8fa
9 changed files with 105 additions and 0 deletions

View File

@ -598,6 +598,18 @@ IF(BUILD_TESTING)
"${CMake_BINARY_DIR}/Tests/SubDir/ShouldBeHere"
"${CMake_BINARY_DIR}/Tests/SubDir/testfromsubdir.o"
)
IF(${CMAKE_GENERATOR} MATCHES "Visual Studio")
ADD_TEST(VSExternalInclude ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/VSExternalInclude"
"${CMake_BINARY_DIR}/Tests/VSExternalInclude"
--build-two-config
--build-generator ${CMAKE_GENERATOR}
--build-project VSExternalInclude
--build-makeprogram ${MAKEPROGRAM}
--test-command VSExternalInclude)
ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio")
IF (APPLE)
ADD_TEST(objc++ ${CMAKE_CTEST_COMMAND}

View File

@ -0,0 +1,38 @@
PROJECT(VSExternalInclude)
IF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
SET(PROJECT_EXT dps)
ELSE(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
SET(PROJECT_EXT vcproj)
ENDIF(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
# make sure directories exists
SET(LIB1_BINARY_DIR ${VSExternalInclude_BINARY_DIR}/Lib1)
MAKE_DIRECTORY("${LIB1_BINARY_DIR}")
SET(LIB2_BINARY_DIR ${VSExternalInclude_BINARY_DIR}/Lib2)
MAKE_DIRECTORY("${LIB2_BINARY_DIR}")
# generate lib1
EXEC_PROGRAM("${CMAKE_COMMAND}" "${LIB1_BINARY_DIR}" ARGS -G\"${CMAKE_GENERATOR}\"
\"${VSExternalInclude_SOURCE_DIR}/Lib1\" OUTPUT_VARIABLE OUT)
# generate lib2
EXEC_PROGRAM("${CMAKE_COMMAND}" "${LIB2_BINARY_DIR}" ARGS -G\"${CMAKE_GENERATOR}\"
\"${VSExternalInclude_SOURCE_DIR}/Lib2\" OUTPUT_VARIABLE OUT)
INCLUDE_EXTERNAL_MSPROJECT(lib1 ${VSExternalInclude_BINARY_DIR}/Lib1/LIB1.${PROJECT_EXT})
# lib2 depends on lib1
INCLUDE_EXTERNAL_MSPROJECT(lib2 ${VSExternalInclude_BINARY_DIR}/Lib2/LIB2.${PROJECT_EXT} lib1)
INCLUDE_DIRECTORIES(${VSExternalInclude_SOURCE_DIR}/Lib2 ${VSExternalInclude_SOURCE_DIR}/Lib1)
SET(SOURCES main.cpp)
ADD_EXECUTABLE(VSExternalInclude ${SOURCES})
# target depends on lib1
ADD_DEPENDENCIES(VSExternalInclude lib2)

View File

@ -0,0 +1,5 @@
PROJECT(LIB1)
SET(SOURCES lib1.cpp)
ADD_LIBRARY(lib1 ${SOURCES})

View File

@ -0,0 +1,7 @@
#include "lib1.h"
int add1(int num)
{
return num + 1;
}

View File

@ -0,0 +1,8 @@
#ifndef LIB1_HPP
#define LIB1_HPP
int add1(int num);
#endif

View File

@ -0,0 +1,7 @@
PROJECT(VSEXTERNAL_LIB2)
INCLUDE_DIRECTORIES(${VSEXTERNAL_LIB2_SOURCE_DIR}/../Lib1)
SET(SOURCES lib2.cpp)
ADD_LIBRARY(lib2 ${SOURCES})

View File

@ -0,0 +1,9 @@
#include "lib2.h"
#include "lib1.h"
int add1_and_mult2(int num)
{
int tmp = add1(num);
return tmp * 2;
}

View File

@ -0,0 +1,10 @@
#ifndef LIB2_HPP
#define LIB2_HPP
#include "lib1.h"
int add1_and_mult2(int num);
#endif

View File

@ -0,0 +1,9 @@
#include "lib2.h"
int main(int argc, char** argv)
{
int num = add1_and_mult2(4);
return 0;
}