CMakeLists.txt 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. cmake_minimum_required (VERSION 2.6)
  2. project(LoadCommand)
  3. # set a definition
  4. set (TEST_COMMAND_TEST1 1)
  5. include (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
  6. CHECK_TYPE_SIZE(char SIZEOF_CHAR)
  7. CHECK_TYPE_SIZE(short SIZEOF_SHORT)
  8. configure_file(${LoadCommand_SOURCE_DIR}/LoadedCommand.h.in
  9. ${LoadCommand_BINARY_DIR}/LoadedCommand.h)
  10. include_directories(${LoadCommand_BINARY_DIR})
  11. # try to compile the command
  12. # make sure it is not already loaded
  13. if(COMMAND CMAKE_TEST_COMMAND)
  14. else()
  15. try_compile(COMPILE_OK
  16. ${LoadCommand_BINARY_DIR}/CMakeCommands
  17. ${LoadCommand_SOURCE_DIR}/CMakeCommands
  18. CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO
  19. OUTPUT_VARIABLE OUTPUT )
  20. # do another TRY_COMPILE to get around make
  21. # problem on hp
  22. try_compile(COMPILE_OK
  23. ${LoadCommand_BINARY_DIR}/CMakeCommands
  24. ${LoadCommand_SOURCE_DIR}/CMakeCommands
  25. CMAKE_LOADED_COMMANDS CMAKE_FLAGS -DMUDSLIDE_TYPE:STRING=MUCHO
  26. OUTPUT_VARIABLE OUTPUT )
  27. endif()
  28. message("Output from try compile: ${OUTPUT}")
  29. # if the compile was OK, try loading the command
  30. if (COMPILE_OK)
  31. load_command(CMAKE_TEST_COMMAND
  32. ${LoadCommand_BINARY_DIR}/CMakeCommands
  33. ${LoadCommand_BINARY_DIR}/CMakeCommands/Debug
  34. ${LoadCommand_BINARY_DIR}/CMakeCommands/Development
  35. )
  36. # if the command loaded, execute the command
  37. if (COMMAND CMAKE_TEST_COMMAND)
  38. CMAKE_TEST_COMMAND(
  39. "${LoadCommand_SOURCE_DIR}/LoadedCommand.cxx.in"
  40. "${LoadCommand_BINARY_DIR}/LoadedCommand2.cxx.in"
  41. "${LoadCommand_BINARY_DIR}/LoadedCommand3.cxx"
  42. )
  43. endif ()
  44. else ()
  45. message("failed to compile CMAKE_LOADED_COMMANDS")
  46. endif ()
  47. # TEST_DEF is set by the loaded command cmTestCommand.c
  48. if (TEST_DEF AND SOME_CACHE_VARIABLE AND TEST_EXEC)
  49. add_definitions(-DCMAKE_IS_FUN)
  50. endif ()