CMakeLists.txt 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. cmake_minimum_required (VERSION 2.6)
  2. project(VSExternalInclude)
  3. if(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
  4. set(PROJECT_EXT dsp)
  5. else()
  6. set(PROJECT_EXT vcproj)
  7. endif()
  8. if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[01]")
  9. set(PROJECT_EXT vcxproj)
  10. endif()
  11. # make sure directories exists
  12. set(LIB1_BINARY_DIR ${VSExternalInclude_BINARY_DIR}/Lib1)
  13. make_directory("${LIB1_BINARY_DIR}")
  14. set(LIB2_BINARY_DIR ${VSExternalInclude_BINARY_DIR}/Lib2)
  15. make_directory("${LIB2_BINARY_DIR}")
  16. # generate lib1
  17. exec_program("${CMAKE_COMMAND}" "${LIB1_BINARY_DIR}" ARGS -G\"${CMAKE_GENERATOR}\"
  18. \"${VSExternalInclude_SOURCE_DIR}/Lib1\" OUTPUT_VARIABLE OUT)
  19. message("CMAKE Ran with the following output:\n\"${OUT}\"")
  20. # generate lib2
  21. exec_program("${CMAKE_COMMAND}" "${LIB2_BINARY_DIR}" ARGS -G\"${CMAKE_GENERATOR}\"
  22. \"${VSExternalInclude_SOURCE_DIR}/Lib2\" OUTPUT_VARIABLE OUT)
  23. message("CMAKE Ran with the following output:\n\"${OUT}\"")
  24. include_external_msproject(lib1 ${VSExternalInclude_BINARY_DIR}/Lib1/LIB1.${PROJECT_EXT})
  25. # lib2 depends on lib1
  26. include_external_msproject(lib2 ${VSExternalInclude_BINARY_DIR}/Lib2/LIB2.${PROJECT_EXT} lib1)
  27. include_directories(${VSExternalInclude_SOURCE_DIR}/Lib2 ${VSExternalInclude_SOURCE_DIR}/Lib1)
  28. set(SOURCES main.cpp)
  29. add_executable(VSExternalInclude ${SOURCES})
  30. # target depends on lib2
  31. add_dependencies(VSExternalInclude lib2)
  32. # VS 10 vcxproj files have depends in them
  33. # Since lib1 and lib2 do not depend on each other
  34. # then the vcxproj files do not depend on each other
  35. # and the sln file can no longer be the only source
  36. # of that depend. So, for VS 10 make the executable
  37. # depend on lib1 and lib2
  38. if(MSVC10 OR MSVC11)
  39. add_dependencies(VSExternalInclude lib1)
  40. endif()
  41. # Interaction testing between the FOLDER target property and
  42. # INCLUDE_EXTERNAL_MSPROJECT targets:
  43. set_target_properties(VSExternalInclude PROPERTIES FOLDER folder1/folder2)
  44. set_target_properties(lib1 PROPERTIES FOLDER folder1/folder2)
  45. set_target_properties(lib2 PROPERTIES FOLDER folder1/folder2)
  46. add_custom_target(EmptyCustomTarget)
  47. set_target_properties(EmptyCustomTarget PROPERTIES FOLDER folder1/folder2)
  48. set_property(GLOBAL PROPERTY USE_FOLDERS ON)