2008-03-25 18:27:18 +03:00
|
|
|
cmake_minimum_required (VERSION 2.6)
|
2012-08-13 21:47:32 +04:00
|
|
|
project(VSExternalInclude)
|
2004-09-15 00:01:00 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
if(${CMAKE_GENERATOR} MATCHES "Visual Studio 6")
|
|
|
|
set(PROJECT_EXT dsp)
|
2012-08-13 21:50:14 +04:00
|
|
|
else()
|
2012-08-13 21:47:32 +04:00
|
|
|
set(PROJECT_EXT vcproj)
|
2012-08-13 21:50:14 +04:00
|
|
|
endif()
|
2014-06-24 23:39:11 +04:00
|
|
|
if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[0124]")
|
2012-08-13 21:47:32 +04:00
|
|
|
set(PROJECT_EXT vcxproj)
|
|
|
|
endif()
|
2004-09-15 00:01:00 +04:00
|
|
|
|
|
|
|
# make sure directories exists
|
2012-08-13 21:47:32 +04:00
|
|
|
set(LIB1_BINARY_DIR ${VSExternalInclude_BINARY_DIR}/Lib1)
|
|
|
|
make_directory("${LIB1_BINARY_DIR}")
|
2004-09-15 00:01:00 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(LIB2_BINARY_DIR ${VSExternalInclude_BINARY_DIR}/Lib2)
|
|
|
|
make_directory("${LIB2_BINARY_DIR}")
|
2004-09-15 00:01:00 +04:00
|
|
|
|
|
|
|
# generate lib1
|
2013-02-06 01:10:36 +04:00
|
|
|
execute_process(
|
|
|
|
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -T "${CMAKE_GENERATOR_TOOLSET}" "${VSExternalInclude_SOURCE_DIR}/Lib1"
|
|
|
|
WORKING_DIRECTORY ${LIB1_BINARY_DIR}
|
|
|
|
OUTPUT_VARIABLE OUT
|
|
|
|
ERROR_VARIABLE OUT
|
|
|
|
)
|
2012-08-13 21:47:32 +04:00
|
|
|
message("CMAKE Ran with the following output:\n\"${OUT}\"")
|
2004-09-15 00:01:00 +04:00
|
|
|
|
|
|
|
# generate lib2
|
2013-02-06 01:10:36 +04:00
|
|
|
execute_process(
|
|
|
|
COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" -T "${CMAKE_GENERATOR_TOOLSET}" "${VSExternalInclude_SOURCE_DIR}/Lib2"
|
|
|
|
WORKING_DIRECTORY ${LIB2_BINARY_DIR}
|
|
|
|
OUTPUT_VARIABLE OUT
|
|
|
|
ERROR_VARIABLE OUT
|
|
|
|
)
|
2012-08-13 21:47:32 +04:00
|
|
|
message("CMAKE Ran with the following output:\n\"${OUT}\"")
|
2004-09-15 00:01:00 +04:00
|
|
|
|
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
include_external_msproject(lib1 ${VSExternalInclude_BINARY_DIR}/Lib1/LIB1.${PROJECT_EXT})
|
2004-09-15 00:01:00 +04:00
|
|
|
# lib2 depends on lib1
|
2012-08-13 21:47:32 +04:00
|
|
|
include_external_msproject(lib2 ${VSExternalInclude_BINARY_DIR}/Lib2/LIB2.${PROJECT_EXT} lib1)
|
2004-09-15 00:01:00 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
include_directories(${VSExternalInclude_SOURCE_DIR}/Lib2 ${VSExternalInclude_SOURCE_DIR}/Lib1)
|
2004-09-15 00:01:00 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
set(SOURCES main.cpp)
|
2004-09-15 00:01:00 +04:00
|
|
|
|
2012-08-13 21:47:32 +04:00
|
|
|
add_executable(VSExternalInclude ${SOURCES})
|
2004-09-15 00:01:00 +04:00
|
|
|
|
2004-09-15 00:34:57 +04:00
|
|
|
# target depends on lib2
|
2012-08-13 21:47:32 +04:00
|
|
|
add_dependencies(VSExternalInclude lib2)
|
2009-07-14 22:16:46 +04:00
|
|
|
# VS 10 vcxproj files have depends in them
|
|
|
|
# Since lib1 and lib2 do not depend on each other
|
|
|
|
# then the vcxproj files do not depend on each other
|
|
|
|
# and the sln file can no longer be the only source
|
|
|
|
# of that depend. So, for VS 10 make the executable
|
|
|
|
# depend on lib1 and lib2
|
2014-06-24 23:39:11 +04:00
|
|
|
if(${CMAKE_GENERATOR} MATCHES "Visual Studio 1[0124]")
|
2012-08-13 21:47:32 +04:00
|
|
|
add_dependencies(VSExternalInclude lib1)
|
|
|
|
endif()
|
2009-07-14 00:58:24 +04:00
|
|
|
|
2010-11-10 17:06:09 +03:00
|
|
|
# Interaction testing between the FOLDER target property and
|
|
|
|
# INCLUDE_EXTERNAL_MSPROJECT targets:
|
|
|
|
set_target_properties(VSExternalInclude PROPERTIES FOLDER folder1/folder2)
|
|
|
|
set_target_properties(lib1 PROPERTIES FOLDER folder1/folder2)
|
|
|
|
set_target_properties(lib2 PROPERTIES FOLDER folder1/folder2)
|
|
|
|
add_custom_target(EmptyCustomTarget)
|
|
|
|
set_target_properties(EmptyCustomTarget PROPERTIES FOLDER folder1/folder2)
|
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|