Skip to content

Commit

Permalink
Group targets into folders
Browse files Browse the repository at this point in the history
This plays nicer with IDEs.
  • Loading branch information
antiagainst committed Apr 6, 2017
1 parent dec3f5e commit 5c3c054
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 7 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
20 changes: 20 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
10 changes: 5 additions & 5 deletions examples/cpp-interface/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
11 changes: 11 additions & 0 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
5 changes: 4 additions & 1 deletion source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions source/opt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 2 additions & 1 deletion tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down

0 comments on commit 5c3c054

Please sign in to comment.