STYLE: Nightly Version update
[cmake.git] / Tests / LoadCommand / CMakeLists.txt
blobf69d29286df2a8c797e4bf5474c66522864b769c
1 PROJECT(LoadedCommand)
3 # set a definition
4 SET (TEST_COMMAND_TEST1 1)
6 INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
7 CHECK_TYPE_SIZE(char  SIZEOF_CHAR)
8 CHECK_TYPE_SIZE(short  SIZEOF_SHORT)
10 INCLUDE (CheckFunctionExists)
11 CHECK_FUNCTION_EXISTS(printf        HAVE_PRINTF)
12 CHECK_FUNCTION_EXISTS(vsblabla      HAVE_VSBLABLA)
14 INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
15 CHECK_INCLUDE_FILE("sys/prctl.h"    HAVE_SYS_PRCTL_H)
17 INCLUDE (${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake)
18 CHECK_LIBRARY_EXISTS(m ceil "" HAVE_LIBM)
20 CONFIGURE_FILE(${LoadedCommand_SOURCE_DIR}/LoadedCommand.h.in
21                ${LoadedCommand_BINARY_DIR}/LoadedCommand.h)
23 INCLUDE_DIRECTORIES(${LoadedCommand_BINARY_DIR})
25 # try to compile the command
26 # make sure it is not already loaded
27 IF(COMMAND CMAKE_TEST_COMMAND)
28 ELSE(COMMAND CMAKE_TEST_COMMAND)
29   TRY_COMPILE(COMPILE_OK 
30     ${LoadedCommand_BINARY_DIR}/CMakeCommands 
31     ${LoadedCommand_SOURCE_DIR}/CMakeCommands 
32     CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO
33     OUTPUT_VARIABLE OUTPUT )
34 # do another TRY_COMPILE to get around make
35 # problem on hp
36   TRY_COMPILE(COMPILE_OK 
37     ${LoadedCommand_BINARY_DIR}/CMakeCommands 
38     ${LoadedCommand_SOURCE_DIR}/CMakeCommands 
39     CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO
40     OUTPUT_VARIABLE OUTPUT )
41 ENDIF(COMMAND CMAKE_TEST_COMMAND)
43 MESSAGE("Output from try compile: ${OUTPUT}")
45 # if the compile was OK, try loading the command
46 IF (COMPILE_OK)
47   LOAD_COMMAND(CMAKE_TEST_COMMAND 
48     ${LoadedCommand_BINARY_DIR}/CMakeCommands 
49     ${LoadedCommand_BINARY_DIR}/CMakeCommands/Debug
50     )
51   # if the command loaded, execute the command
52   IF (COMMAND CMAKE_TEST_COMMAND)
53     CMAKE_TEST_COMMAND()
54   ENDIF (COMMAND CMAKE_TEST_COMMAND)
55 ELSE (COMPILE_OK)
56   MESSAGE("failed to compile CMAKE_LOADED_COMMANDS")
57 ENDIF (COMPILE_OK)
59 # TEST_DEF is set by the loaded command cmTestCommand.c
60 IF (TEST_DEF AND SOME_CACHE_VARIABLE)
61   ADD_DEFINITIONS(-DCMAKE_IS_FUN)
62 ENDIF (TEST_DEF AND SOME_CACHE_VARIABLE)
64 ADD_EXECUTABLE (LoadedCommand LoadedCommand.cxx)