1 cmake_minimum_required (VERSION 2.6)
5 SET (TEST_COMMAND_TEST1 1)
7 INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
8 CHECK_TYPE_SIZE(char SIZEOF_CHAR)
9 CHECK_TYPE_SIZE(short SIZEOF_SHORT)
11 INCLUDE (CheckFunctionExists)
12 CHECK_FUNCTION_EXISTS(printf HAVE_PRINTF)
13 CHECK_FUNCTION_EXISTS(vsblabla HAVE_VSBLABLA)
15 INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
16 CHECK_INCLUDE_FILE("sys/prctl.h" HAVE_SYS_PRCTL_H)
18 INCLUDE (${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake)
19 CHECK_LIBRARY_EXISTS(m ceil "" HAVE_LIBM)
21 CONFIGURE_FILE(${LoadCommand_SOURCE_DIR}/LoadedCommand.h.in
22 ${LoadCommand_BINARY_DIR}/LoadedCommand.h)
24 INCLUDE_DIRECTORIES(${LoadCommand_BINARY_DIR})
26 # try to compile the command
27 # make sure it is not already loaded
28 IF(COMMAND CMAKE_TEST_COMMAND)
29 ELSE(COMMAND CMAKE_TEST_COMMAND)
30 TRY_COMPILE(COMPILE_OK
31 ${LoadCommand_BINARY_DIR}/CMakeCommands
32 ${LoadCommand_SOURCE_DIR}/CMakeCommands
33 CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO
34 OUTPUT_VARIABLE OUTPUT )
35 # do another TRY_COMPILE to get around make
37 TRY_COMPILE(COMPILE_OK
38 ${LoadCommand_BINARY_DIR}/CMakeCommands
39 ${LoadCommand_SOURCE_DIR}/CMakeCommands
40 CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO
41 OUTPUT_VARIABLE OUTPUT )
42 ENDIF(COMMAND CMAKE_TEST_COMMAND)
44 MESSAGE("Output from try compile: ${OUTPUT}")
46 # if the compile was OK, try loading the command
48 LOAD_COMMAND(CMAKE_TEST_COMMAND
49 ${LoadCommand_BINARY_DIR}/CMakeCommands
50 ${LoadCommand_BINARY_DIR}/CMakeCommands/Debug
51 ${LoadCommand_BINARY_DIR}/CMakeCommands/Development
53 # if the command loaded, execute the command
54 IF (COMMAND CMAKE_TEST_COMMAND)
56 "${LoadCommand_SOURCE_DIR}/LoadedCommand.cxx.in"
57 "${LoadCommand_BINARY_DIR}/LoadedCommand2.cxx.in"
58 "${LoadCommand_BINARY_DIR}/LoadedCommand3.cxx"
60 ENDIF (COMMAND CMAKE_TEST_COMMAND)
62 MESSAGE("failed to compile CMAKE_LOADED_COMMANDS")
65 # TEST_DEF is set by the loaded command cmTestCommand.c
66 IF (TEST_DEF AND SOME_CACHE_VARIABLE AND TEST_EXEC)
67 ADD_DEFINITIONS(-DCMAKE_IS_FUN)
68 ENDIF (TEST_DEF AND SOME_CACHE_VARIABLE AND TEST_EXEC)