CMakeLists.txt 937 B

1234567891011121314151617181920212223242526272829303132333435
  1. cmake_minimum_required(VERSION 2.8)
  2. project(OutDir C)
  3. if(CMAKE_CONFIGURATION_TYPES)
  4. foreach(config ${CMAKE_CONFIGURATION_TYPES})
  5. string(TOUPPER "${config}" CONFIG)
  6. list(APPEND configs "${CONFIG}")
  7. endforeach()
  8. set(CMAKE_BUILD_TYPE)
  9. elseif(NOT CMAKE_BUILD_TYPE)
  10. set(CMAKE_BUILD_TYPE Debug)
  11. endif()
  12. if(CMAKE_BUILD_TYPE)
  13. string(TOUPPER "${CMAKE_BUILD_TYPE}" configs)
  14. endif()
  15. set(top "${OutDir_BINARY_DIR}")
  16. foreach(config ${configs})
  17. foreach(type archive runtime library)
  18. string(TOUPPER "${type}" TYPE)
  19. set(CMAKE_${TYPE}_OUTPUT_DIRECTORY_${config} "${top}/${type}")
  20. file(REMOVE_RECURSE "${top}/${type}")
  21. endforeach()
  22. endforeach()
  23. add_subdirectory(../COnly COnly)
  24. add_custom_command(
  25. OUTPUT OutDir.h
  26. COMMAND ${CMAKE_COMMAND} -Dtop=${top} -P ${OutDir_SOURCE_DIR}/OutDir.cmake
  27. DEPENDS COnly ${OutDir_SOURCE_DIR}/OutDir.cmake
  28. )
  29. include_directories(${top})
  30. add_executable(OutDir OutDir.c OutDir.h)