Group targets into folders

This plays nicer with IDEs.
This commit is contained in:
Lei Zhang 2017-04-05 17:32:39 -04:00 committed by Lei Zhang
parent dec3f5e231
commit 5c3c054c1f
8 changed files with 46 additions and 7 deletions

View File

@ -19,6 +19,7 @@ if (POLICY CMP0054)
# https://cmake.org/cmake/help/v3.1/policy/CMP0054.html
cmake_policy(SET CMP0054 NEW)
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
project(spirv-tools)
enable_testing()

View File

@ -12,4 +12,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Add a SPIR-V Tools example. Signature:
# add_spvtools_example(
# TARGET target_name
# SRCS src_file1.cpp src_file2.cpp
# LIBS lib_target1 lib_target2
# )
function(add_spvtools_example)
if (NOT ${SPIRV_SKIP_EXECUTABLES})
set(one_value_args TARGET)
set(multi_value_args SRCS LIBS)
cmake_parse_arguments(
ARG "" "${one_value_args}" "${multi_value_args}" ${ARGN})
add_executable(${ARG_TARGET} ${ARG_SRCS})
spvtools_default_compile_options(${ARG_TARGET})
target_link_libraries(${ARG_TARGET} PRIVATE ${ARG_LIBS})
set_property(TARGET ${ARG_TARGET} PROPERTY FOLDER "SPIRV-Tools examples")
endif()
endfunction()
add_subdirectory(cpp-interface)

View File

@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if (NOT ${SPIRV_SKIP_EXECUTABLES})
add_executable(spirv-tools-cpp-example main.cpp)
spvtools_default_compile_options(spirv-tools-cpp-example)
target_link_libraries(spirv-tools-cpp-example PRIVATE SPIRV-Tools-opt)
endif()
add_spvtools_example(
TARGET spirv-tools-cpp-example
SRCS main.cpp
LIBS SPIRV-Tools-opt
)

View File

@ -43,4 +43,15 @@ if (NOT ${SPIRV_SKIP_EXECUTABLES})
add_subdirectory(${GMOCK_DIR})
endif()
endif()
if (TARGET gmock)
set(GTEST_TARGETS
gtest
gtest_main
gmock
gmock_main
)
foreach(target ${GTEST_TARGETS})
set_property(TARGET ${target} PROPERTY FOLDER GoogleTest)
endforeach()
endif()
endif()

View File

@ -106,6 +106,7 @@ macro(spvtools_vendor_tables VENDOR_TABLE)
COMMENT "Generate extended instruction tables for ${VENDOR_TABLE}.")
list(APPEND EXTINST_CPP_DEPENDS ${INSTS_FILE})
add_custom_target(spirv-tools-${VENDOR_TABLE} DEPENDS ${INSTS_FILE})
set_property(TARGET spirv-tools-${VENDOR_TABLE} PROPERTY FOLDER "SPIRV-Tools build")
endmacro(spvtools_vendor_tables)
spvtools_core_tables("1.0")
@ -117,7 +118,7 @@ spvtools_vendor_tables("spv-amd-gcn-shader")
spvtools_vimsyntax("1.1" "1.0")
add_custom_target(spirv-tools-vimsyntax DEPENDS ${VIMSYNTAX_FILE})
set_property(TARGET spirv-tools-vimsyntax PROPERTY FOLDER "SPIRV-Tools utilities")
# Extract the list of known generators from the SPIR-V XML registry file.
set(GENERATOR_INC_FILE ${spirv-tools_BINARY_DIR}/generators.inc)
@ -181,6 +182,7 @@ add_custom_command(OUTPUT ${SPIRV_TOOLS_BUILD_VERSION_INC}
# This is not required for any dependence chain.
add_custom_target(spirv-tools-build-version
DEPENDS ${SPIRV_TOOLS_BUILD_VERSION_INC})
set_property(TARGET spirv-tools-build-version PROPERTY FOLDER "SPIRV-Tools build")
add_subdirectory(opt)
@ -276,6 +278,7 @@ target_include_directories(${SPIRV_TOOLS}
PRIVATE ${spirv-tools_BINARY_DIR}
PRIVATE ${SPIRV_HEADER_INCLUDE_DIR}
)
set_property(TARGET ${SPIRV_TOOLS} PROPERTY FOLDER "SPIRV-Tools libraries")
install(TARGETS ${SPIRV_TOOLS}
RUNTIME DESTINATION bin

View File

@ -66,6 +66,8 @@ target_include_directories(SPIRV-Tools-opt
target_link_libraries(SPIRV-Tools-opt
PUBLIC ${SPIRV_TOOLS})
set_property(TARGET SPIRV-Tools-opt PROPERTY FOLDER "SPIRV-Tools libraries")
install(TARGETS SPIRV-Tools-opt
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib

View File

@ -59,6 +59,7 @@ function(add_spvtools_unittest)
target_link_libraries(${target} PRIVATE ${ARG_LIBS})
target_link_libraries(${target} PRIVATE gmock_main)
add_test(NAME spirv-tools-${target} COMMAND ${target})
set_property(TARGET ${target} PROPERTY FOLDER "SPIRV-Tools tests")
endif()
endfunction()

View File

@ -33,7 +33,8 @@ function(add_spvtools_tool)
target_include_directories(${ARG_TARGET} PRIVATE
${spirv-tools_SOURCE_DIR}
${spirv-tools_BINARY_DIR}
)
)
set_property(TARGET ${ARG_TARGET} PROPERTY FOLDER "SPIRV-Tools executables")
endfunction()
if (NOT ${SPIRV_SKIP_EXECUTABLES})