ENH: Add install test

This commit is contained in:
Andy Cedilnik 2004-02-01 12:53:28 -05:00
parent 48dc13a649
commit 2106bdc4ec
21 changed files with 250 additions and 4 deletions

View File

@ -238,6 +238,20 @@ IF(BUILD_TESTING)
--build-two-config --build-two-config
--test-command conly) --test-command conly)
SET(SimpleInstallInstallDir
"${CMake_BINARY_DIR}/Tests/SimpleInstall/Install Directory")
ADD_TEST(SimpleInstall ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/SimpleInstall"
"${CMake_BINARY_DIR}/Tests/SimpleInstall"
--build-generator ${CMAKE_GENERATOR}
--build-project TestSimpleInstall
--build-makeprogram ${MAKEPROGRAM}
--build-two-config
--build-options
"-DCMAKE_INSTALL_PREFIX:PATH=${SimpleInstallInstallDir}"
--test-command ${SimpleInstallInstallDir}/bin/SimpleInstall)
ADD_TEST(X11 ${CMAKE_CTEST_COMMAND} ADD_TEST(X11 ${CMAKE_CTEST_COMMAND}
--build-and-test --build-and-test
"${CMake_SOURCE_DIR}/Tests/X11" "${CMake_SOURCE_DIR}/Tests/X11"
@ -554,14 +568,14 @@ IF(BUILD_TESTING)
ENDIF (CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE OR WXWINDOWS_INCLUDE_DIR) ENDIF (CMAKE_WXWINDOWS_WXCONFIG_EXECUTABLE OR WXWINDOWS_INCLUDE_DIR)
IF(UNIX) IF(UNIX)
IF("x${CMAKE_INSTALL_PREFIX}" MATCHES "^x${CMake_BINARY_DIR}/Tests/TestInstall/Prefix$") IF("x${CMAKE_INSTALL_PREFIX}" MATCHES "^x${CMake_BINARY_DIR}/Tests/TestShellInstall/Prefix$")
CONFIGURE_FILE( CONFIGURE_FILE(
${CMake_SOURCE_DIR}/Tests/TestInstall.sh.in ${CMake_SOURCE_DIR}/Tests/TestInstall.sh.in
${CMake_BINARY_DIR}/Tests/TestInstall/TestInstall.sh ${CMake_BINARY_DIR}/Tests/TestShellInstall/TestInstall.sh
@ONLY IMMEDIATE @ONLY IMMEDIATE
) )
ADD_TEST(Install /bin/sh ${CMake_BINARY_DIR}/Tests/TestInstall/TestInstall.sh) ADD_TEST(ShellInstall /bin/sh ${CMake_BINARY_DIR}/Tests/TestShellInstall/TestShellInstall.sh)
ENDIF("x${CMAKE_INSTALL_PREFIX}" MATCHES "^x${CMake_BINARY_DIR}/Tests/TestInstall/Prefix$") ENDIF("x${CMAKE_INSTALL_PREFIX}" MATCHES "^x${CMake_BINARY_DIR}/Tests/TestShellInstall/Prefix$")
ENDIF(UNIX) ENDIF(UNIX)
ENDIF(BUILD_TESTING) ENDIF(BUILD_TESTING)

View File

@ -0,0 +1,36 @@
PROJECT (TestSimpleInstall)
#SET(EXECUTABLE_OUTPUT_PATH "${TestSimpleInstall_BINARY_DIR}/This is exec path")
SET(EXECUTABLE_OUTPUT_PATH "${TestSimpleInstall_BINARY_DIR}/ExecPath")
SET(LIBRARY_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}")
SET(CMAKE_DEBUG_POSTFIX "_test_debug_postfix")
ADD_LIBRARY(test1 STATIC lib1.cxx)
ADD_LIBRARY(test2 SHARED lib2.cxx)
ADD_LIBRARY(test3 MODULE lib3.cxx)
ADD_EXECUTABLE (SimpleInstall inst.cxx foo.c foo.h)
TARGET_LINK_LIBRARIES(SimpleInstall test1 test2)
INSTALL_TARGETS(/bin SimpleInstall)
INSTALL_TARGETS(/lib test1 test2 test3)
INSTALL_TARGETS(/include lib1.h lib2.h lib3.h)
SET(EXTRA_INSTALL_FLAGS)
IF(CMAKE_GENERATOR MATCHES "^Visual Studio")
FOREACH(build_type Debug Release RelWithDebInfo MinSizeRel)
IF(MAKEPROGRAM MATCHES "/build ${build_type}")
SET(EXTRA_INSTALL_FLAGS -DBUILD_TYPE=${build_type})
ENDIF(MAKEPROGRAM MATCHES "/build ${build_type}")
IF(MAKEPROGRAM MATCHES "- ${build_type}")
SET(EXTRA_INSTALL_FLAGS -DBUILD_TYPE=${build_type})
ENDIF(MAKEPROGRAM MATCHES "- ${build_type}")
ENDFOREACH(build_type)
ENDIF(CMAKE_GENERATOR MATCHES "^Visual Studio")
ADD_CUSTOM_COMMAND(
TARGET SimpleInstall
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -Pcmake_install.cmake ${EXTRA_INSTALL_FLAGS}
COMMENT "Install Project"
)

View File

@ -0,0 +1,6 @@
char* foo = "Foo";
int SomeFunctionInFoo(int i)
{
return i + 5;
}

11
Tests/SimpleInstall/foo.h Normal file
View File

@ -0,0 +1,11 @@
#ifdef __cplusplus
extern "C" {
#endif
extern char* foo;
extern int SomeFunctionInFoo(int i);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,22 @@
#include "foo.h"
#include "lib1.h"
#include "lib2.h"
#include <stdio.h>
int main ()
{
if ( Lib1Func() != 2.0 )
{
printf("Problem with lib1\n");
return 1;
}
if ( Lib2Func() != 1.0 )
{
printf("Problem with lib2\n");
return 1;
}
printf("Foo: %s\n", foo);
return SomeFunctionInFoo(-5);
}

View File

@ -0,0 +1,6 @@
#include "lib1.h"
float Lib1Func()
{
return 2.0;
}

View File

@ -0,0 +1 @@
extern float Lib1Func();

View File

@ -0,0 +1,6 @@
#include "lib2.h"
float Lib2Func()
{
return 1.0;
}

View File

@ -0,0 +1,11 @@
#ifdef _WIN32
# ifdef testc2_EXPORTS
# define CM_TEST_LIB_EXPORT __declspec( dllexport )
# else
# define CM_TEST_LIB_EXPORT __declspec( dllimport )
# endif
#else
# define CM_TEST_LIB_EXPORT
#endif
CM_TEST_LIB_EXPORT float Lib2Func();

View File

@ -0,0 +1,6 @@
#include "lib3.h"
float Lib3Func()
{
return 2.0;
}

View File

@ -0,0 +1,11 @@
#ifdef _WIN32
# ifdef testc3_EXPORTS
# define CM_TEST_LIB_EXPORT __declspec( dllexport )
# else
# define CM_TEST_LIB_EXPORT __declspec( dllimport )
# endif
#else
# define CM_TEST_LIB_EXPORT
#endif
CM_TEST_LIB_EXPORT float Lib3Func();

View File

@ -0,0 +1,36 @@
PROJECT (TestSimpleInstall)
#SET(EXECUTABLE_OUTPUT_PATH "${TestSimpleInstall_BINARY_DIR}/This is exec path")
SET(EXECUTABLE_OUTPUT_PATH "${TestSimpleInstall_BINARY_DIR}/ExecPath")
SET(LIBRARY_OUTPUT_PATH "${EXECUTABLE_OUTPUT_PATH}")
SET(CMAKE_DEBUG_POSTFIX "_test_debug_postfix")
ADD_LIBRARY(test1 STATIC lib1.cxx)
ADD_LIBRARY(test2 SHARED lib2.cxx)
ADD_LIBRARY(test3 MODULE lib3.cxx)
ADD_EXECUTABLE (SimpleInstall inst.cxx foo.c foo.h)
TARGET_LINK_LIBRARIES(SimpleInstall test1 test2)
INSTALL_TARGETS(/bin SimpleInstall)
INSTALL_TARGETS(/lib test1 test2 test3)
INSTALL_TARGETS(/include lib1.h lib2.h lib3.h)
SET(EXTRA_INSTALL_FLAGS)
IF(CMAKE_GENERATOR MATCHES "^Visual Studio")
FOREACH(build_type Debug Release RelWithDebInfo MinSizeRel)
IF(MAKEPROGRAM MATCHES "/build ${build_type}")
SET(EXTRA_INSTALL_FLAGS -DBUILD_TYPE=${build_type})
ENDIF(MAKEPROGRAM MATCHES "/build ${build_type}")
IF(MAKEPROGRAM MATCHES "- ${build_type}")
SET(EXTRA_INSTALL_FLAGS -DBUILD_TYPE=${build_type})
ENDIF(MAKEPROGRAM MATCHES "- ${build_type}")
ENDFOREACH(build_type)
ENDIF(CMAKE_GENERATOR MATCHES "^Visual Studio")
ADD_CUSTOM_COMMAND(
TARGET SimpleInstall
POST_BUILD
COMMAND ${CMAKE_COMMAND}
ARGS -Pcmake_install.cmake ${EXTRA_INSTALL_FLAGS}
COMMENT "Install Project"
)

View File

@ -0,0 +1,6 @@
char* foo = "Foo";
int SomeFunctionInFoo(int i)
{
return i + 5;
}

View File

@ -0,0 +1,11 @@
#ifdef __cplusplus
extern "C" {
#endif
extern char* foo;
extern int SomeFunctionInFoo(int i);
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,22 @@
#include "foo.h"
#include "lib1.h"
#include "lib2.h"
#include <stdio.h>
int main ()
{
if ( Lib1Func() != 2.0 )
{
printf("Problem with lib1\n");
return 1;
}
if ( Lib2Func() != 1.0 )
{
printf("Problem with lib2\n");
return 1;
}
printf("Foo: %s\n", foo);
return SomeFunctionInFoo(-5);
}

View File

@ -0,0 +1,6 @@
#include "lib1.h"
float Lib1Func()
{
return 2.0;
}

View File

@ -0,0 +1 @@
extern float Lib1Func();

View File

@ -0,0 +1,6 @@
#include "lib2.h"
float Lib2Func()
{
return 1.0;
}

View File

@ -0,0 +1,11 @@
#ifdef _WIN32
# ifdef testc2_EXPORTS
# define CM_TEST_LIB_EXPORT __declspec( dllexport )
# else
# define CM_TEST_LIB_EXPORT __declspec( dllimport )
# endif
#else
# define CM_TEST_LIB_EXPORT
#endif
CM_TEST_LIB_EXPORT float Lib2Func();

View File

@ -0,0 +1,6 @@
#include "lib3.h"
float Lib3Func()
{
return 2.0;
}

View File

@ -0,0 +1,11 @@
#ifdef _WIN32
# ifdef testc3_EXPORTS
# define CM_TEST_LIB_EXPORT __declspec( dllexport )
# else
# define CM_TEST_LIB_EXPORT __declspec( dllimport )
# endif
#else
# define CM_TEST_LIB_EXPORT
#endif
CM_TEST_LIB_EXPORT float Lib3Func();