Cmake refactor part 7

generate project source tree in all projects with sources
source tree is based on real paths

Change-Id: Ie10a6bffedb8020f25ebcb24a2f797086d8accbb
This commit is contained in:
Mateusz Jablonski
2018-03-01 11:59:54 +01:00
committed by sys_ocldev
parent 8f0789bd3e
commit 2466f9363f
16 changed files with 82 additions and 128 deletions

View File

@@ -32,15 +32,23 @@ macro(add_subdirectories)
endmacro()
macro(create_project_source_tree target)
get_target_property(source_list ${target} SOURCES)
foreach(source_file ${source_list})
if(NOT ${source_file} MATCHES "\<*\>")
file(RELATIVE_PATH source_file_relative ${CMAKE_CURRENT_SOURCE_DIR} ${source_file})
get_filename_component(source_path_relative ${source_file_relative} PATH)
if(source_path_relative)
string(REPLACE "/" "\\" source_path_relative ${source_path_relative})
if(MSVC)
set(prefixes ${CMAKE_CURRENT_SOURCE_DIR} ${ARGN})
get_target_property(source_list ${target} SOURCES)
foreach(source_file ${source_list})
if(NOT ${source_file} MATCHES "\<*\>")
set(source_file_relative ${source_file})
foreach(prefix ${prefixes})
if(source_file_relative)
string(REPLACE "${prefix}" "" source_file_relative ${source_file_relative})
endif()
endforeach()
get_filename_component(source_path_relative ${source_file_relative} PATH)
if(source_path_relative)
string(REPLACE "/" "\\" source_path_relative ${source_path_relative})
endif()
source_group("Source Files\\${source_path_relative}" FILES ${source_file})
endif()
source_group("Source Files\\${source_path_relative}" FILES ${source_file})
endif()
endforeach()
endforeach()
endif()
endmacro()

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2017, Intel Corporation
# Copyright (c) 2017 - 2018, Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
@@ -18,18 +18,17 @@
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# We require cmake 3.2.0 or later
cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR)
add_library(elflib STATIC
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/reader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/reader.h
${CMAKE_CURRENT_SOURCE_DIR}/types.h
${CMAKE_CURRENT_SOURCE_DIR}/writer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/writer.h
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/reader.cpp
${CMAKE_CURRENT_SOURCE_DIR}/reader.h
${CMAKE_CURRENT_SOURCE_DIR}/types.h
${CMAKE_CURRENT_SOURCE_DIR}/writer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/writer.h
)
create_project_source_tree(elflib)
target_include_directories(elflib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(elflib PRIVATE ${IGDRCL_SOURCE_DIR})

View File

@@ -79,11 +79,11 @@ endforeach(GEN_NUM)
set(CLOC_SRCS
${CLOC_SRCS_LIB}
main.cpp
${IGDRCL_SOURCE_DIR}/offline_compiler/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
)
add_executable(cloc ${CLOC_SRCS})
create_project_source_tree(cloc ${IGDRCL_SOURCE_DIR}/runtime)
if(IGC_OCL_ADAPTOR_DIR) # IGC/AdaptorOCL
target_include_directories(cloc PUBLIC "${IGC_OCL_ADAPTOR_DIR}")
@@ -112,7 +112,6 @@ endif(UNIX)
target_link_libraries(cloc elflib)
source_group("source files" FILES ${CLOC_SRCS})
set_target_properties(cloc PROPERTIES FOLDER "offline_compiler")
set_property(TARGET cloc APPEND_STRING PROPERTY COMPILE_FLAGS ${ASAN_FLAGS} ${TSAN_FLAGS})

View File

@@ -193,11 +193,10 @@ if(${GENERATE_EXECUTABLE})
OUTPUT_NAME "${NEO_DLL_NAME_BASE}${IGDRCL_NAME_POSTFIX}${IGDRCL_OPTION__BITS}"
)
set_target_properties(${NEO_DYNAMIC_LIB_NAME} PROPERTIES FOLDER "opencl runtime")
create_project_source_tree(${NEO_DYNAMIC_LIB_NAME})
endif(${GENERATE_EXECUTABLE})
if(WIN32)
create_project_source_tree(${NEO_STATIC_LIB_NAME})
endif()
create_project_source_tree(${NEO_STATIC_LIB_NAME})
if(UNIX AND NOT (TARGET clang-tidy))
add_custom_target(clang-tidy

View File

@@ -48,3 +48,5 @@ else()
endif()
add_subdirectories()
create_project_source_tree(${SHARINGS_ENABLE_LIB_NAME} ${IGDRCL_SOURCE_DIR}/runtime)

View File

@@ -327,43 +327,8 @@ else (MSVC)
endif(PRE_ULT_COMMAND)
endif (MSVC)
source_group("source files" FILES ${IGDRCL_SRCS_tests_local})
source_group("source files\\accelerators" FILES ${IGDRCL_SRCS_tests_accelerators})
source_group("source files\\api" FILES ${IGDRCL_SRCS_tests_api})
source_group("source files\\built_ins" FILES ${IGDRCL_SRCS_built_in_tests})
source_group("source files\\command_queue" FILES ${IGDRCL_SRCS_tests_command_queue})
source_group("source files\\command_stream" FILES ${IGDRCL_SRCS_tests_command_stream})
source_group("source files\\compiler_interface" FILES ${IGDRCL_SRCS_tests_compiler_interface})
source_group("source files\\context" FILES ${IGDRCL_SRCS_tests_context})
source_group("source files\\device" FILES ${IGDRCL_SRCS_tests_device})
source_group("source files\\device_queue" FILES ${IGDRCL_SRCS_tests_device_queue})
source_group("source files\\event" FILES ${IGDRCL_SRCS_tests_event})
source_group("source files\\execution_model" FILES ${IGDRCL_SRCS_tests_execution_model})
source_group("source files\\fixtures" FILES ${IGDRCL_SRCS_tests_fixtures})
source_group("source files\\gen_common" FILES ${IGDRCL_SRCS_tests_gen_common})
source_group("source files\\gmm_helper" FILES ${IGDRCL_SRCS_tests_gmm_helper})
source_group("source files\\helpers" FILES ${IGDRCL_SRCS_tests_helpers})
source_group("source files\\indirect_heap" FILES ${IGDRCL_SRCS_tests_indirect_heap})
source_group("source files\\instrumentation" FILES ${IGDRCL_SRCS_tests_instrumentation})
source_group("source files\\kernel" FILES ${IGDRCL_SRCS_tests_kernel})
source_group("source files\\mem_obj" FILES ${IGDRCL_SRCS_tests_mem_obj})
source_group("source files\\memory_manager" FILES ${IGDRCL_SRCS_tests_memory_manager})
source_group("source files\\os_interface" FILES ${IGDRCL_SRCS_tests_os_interface})
source_group("source files\\platform" FILES ${IGDRCL_SRCS_tests_platform})
source_group("source files\\preamble" FILES ${IGDRCL_SRCS_tests_preamble})
source_group("source files\\preemption" FILES ${IGDRCL_SRCS_tests_preemption})
source_group("source files\\profiling" FILES ${IGDRCL_SRCS_tests_profiling})
source_group("source files\\program" FILES ${IGDRCL_SRCS_tests_program})
source_group("source files\\sampler" FILES ${IGDRCL_SRCS_tests_sampler})
source_group("source files\\scenarios" FILES ${IGDRCL_SRCS_tests_scenarios})
source_group("source files\\scheduler" FILES ${IGDRCL_SRCS_tests_scheduler})
source_group("source files\\sku_info" FILES ${IGDRCL_SRCS_tests_sku_info})
source_group("source files\\sharings" FILES ${IGDRCL_SRCS_tests_sharings})
source_group("source files\\utilities" FILES ${IGDRCL_SRCS_tests_utilities})
create_project_source_tree(igdrcl_tests ${IGDRCL_SOURCE_DIR}/runtime)
if(MSVC)
source_group("source files\\d3d_sharing" FILES ${IGDRCL_SRCS_tests_d3d_sharing})
endif()
set_target_properties(igdrcl_tests PROPERTIES FOLDER "opencl runtime")
set_property(TARGET igdrcl_tests APPEND_STRING PROPERTY COMPILE_FLAGS ${ASAN_FLAGS})
if(NOT MSVC)

View File

@@ -55,9 +55,7 @@ add_subdirectory(command_stream)
add_subdirectory(fixtures)
add_subdirectory(mem_obj)
target_sources(igdrcl_aub_tests PUBLIC
target_sources(igdrcl_aub_tests PRIVATE
${IGDRCL_SOURCE_DIR}/unit_tests/command_queue/command_queue_fixture.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/fixtures/buffer_fixture.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/fixtures/built_in_fixture.cpp
@@ -78,14 +76,14 @@ target_sources(igdrcl_aub_tests PUBLIC
)
if(MSVC)
target_sources(igdrcl_aub_tests PUBLIC
target_sources(igdrcl_aub_tests PRIVATE
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/windows/options.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/windows/ult_dxgi_factory.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/windows/wddm_create.cpp
${IGDRCL_SOURCE_DIR}/runtime/gmm_helper/gmm_memory.cpp
)
else(MSVC)
target_sources(igdrcl_aub_tests PUBLIC
target_sources(igdrcl_aub_tests PRIVATE
${IGDRCL_SOURCE_DIR}/unit_tests/os_interface/linux/options.cpp
)
endif(MSVC)
@@ -99,6 +97,7 @@ target_link_libraries(igdrcl_aub_tests igdrcl_mocks)
target_link_libraries(igdrcl_aub_tests gtest gmock)
link_directories(${GMM_LIB_PATHS})
create_project_source_tree(igdrcl_aub_tests ${IGDRCL_SOURCE_DIR}/runtime ${IGDRCL_SOURCE_DIR}/unit_tests)
if(MSVC)
target_link_libraries(igdrcl_aub_tests Ws2_32.lib)

View File

@@ -18,17 +18,15 @@
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR)
project(elflib_tests)
set(CLELFLIB_UNIT_TESTS_SRCS
"${CMAKE_CURRENT_SOURCE_DIR}/elflib_tests.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
"${IGDRCL_SOURCE_DIR}/unit_tests/fixtures/memory_management_fixture.cpp"
"${IGDRCL_SOURCE_DIR}/unit_tests/fixtures/memory_management_fixture.h"
"${IGDRCL_SOURCE_DIR}/unit_tests/helpers/memory_management.cpp"
"${IGDRCL_SOURCE_DIR}/unit_tests/helpers/memory_management.h"
${CMAKE_CURRENT_SOURCE_DIR}/elflib_tests.cpp
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/fixtures/memory_management_fixture.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/fixtures/memory_management_fixture.h
${IGDRCL_SOURCE_DIR}/unit_tests/helpers/memory_management.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/helpers/memory_management.h
)
add_executable(elflib_tests ${CLELFLIB_UNIT_TESTS_SRCS})
@@ -52,7 +50,6 @@ add_custom_command(
)
add_dependencies(run_unit_tests run_elflib_tests)
# The following filters are added to the VS IDE representation
set_target_properties(elflib_tests PROPERTIES FOLDER "elflib")
set_target_properties(run_elflib_tests PROPERTIES FOLDER "elflib")
source_group("source files" FILES ${CLELFLIB_UNIT_TESTS_SRCS})
create_project_source_tree(elflib_tests ${IGDRCL_SOURCE_DIR}/unit_tests)

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2017, Intel Corporation
# Copyright (c) 2017 - 2018, Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
@@ -18,13 +18,8 @@
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
# This is a child cmakelists.txt file of the OpenCL unit test project
set(IGDRCL_SRCS_tests_gtpin
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt"
"${CMAKE_CURRENT_SOURCE_DIR}/gtpin_tests.cpp"
PARENT_SCOPE
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/gtpin_tests.cpp
PARENT_SCOPE
)
source_group("source files\\gtpin" FILES ${IGDRCL_SRCS_tests_gtpin})

View File

@@ -50,7 +50,7 @@ foreach(GEN_NUM RANGE 0 ${MAX_GEN} 1)
endif(${GENX_HAS_PLATFORMS})
endforeach(GEN_NUM)
list (APPEND IGDRCL_SRCS_LIB_ULT
list(APPEND IGDRCL_SRCS_LIB_ULT
${IGDRCL_SOURCE_DIR}/unit_tests/libult/create_tbx_sockets.cpp
${IGDRCL_SOURCE_DIR}/unit_tests/libult/ult_command_stream_receiver.h
${IGDRCL_SOURCE_DIR}/unit_tests/helpers/debug_helpers.cpp
@@ -66,9 +66,12 @@ add_library (igdrcl_libult_cs OBJECT
${IGDRCL_SOURCE_DIR}/unit_tests/libult/create_command_stream.h
)
create_project_source_tree(igdrcl_libult ${IGDRCL_SOURCE_DIR}/runtime ${IGDRCL_SOURCE_DIR}/unit_tests)
create_project_source_tree(igdrcl_libult_cs ${IGDRCL_SOURCE_DIR}/runtime ${IGDRCL_SOURCE_DIR}/unit_tests)
if(MSVC)
target_include_directories(igdrcl_libult PRIVATE ${WDK_INCLUDE_PATHS})
endif(MSVC)
endif()
if (WIN32)
target_compile_definitions(igdrcl_libult PUBLIC OGL=1)

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2017, Intel Corporation
# Copyright (c) 2017 - 2018, Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
@@ -18,23 +18,21 @@
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR)
project(mock_gdi)
set(DEF_FILE "${CMAKE_CURRENT_SOURCE_DIR}/gdi32_mock.def")
# Setting up our local list of test files
set(IGDRCL_SRCS_tests_mock_gdi
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt"
"${CMAKE_CURRENT_SOURCE_DIR}/mock_gdi.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/mock_gdi.h"
"${DEF_FILE}"
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
${CMAKE_CURRENT_SOURCE_DIR}/mock_gdi.cpp
${CMAKE_CURRENT_SOURCE_DIR}/mock_gdi.h
${DEF_FILE}
)
# need to find our static lib
link_directories(
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
)
# this is a DLL
@@ -43,21 +41,21 @@ add_library(mock_gdi SHARED ${IGDRCL_SRCS_tests_mock_gdi})
add_definitions(-DINSIDE_PLUGIN)
target_include_directories(mock_gdi PRIVATE
${WDK_INCLUDE_PATHS}
${UMKM_SHAREDDATA_INCLUDE_PATHS}
${GMM_INCLUDE_PATHS}
${KHRONOS_HEADERS_DIR}
${WDK_INCLUDE_PATHS}
${UMKM_SHAREDDATA_INCLUDE_PATHS}
${GMM_INCLUDE_PATHS}
${KHRONOS_HEADERS_DIR}
)
set_target_properties(
mock_gdi
PROPERTIES DEBUG_OUTPUT_NAME "gdi32_mock"
RELEASE_OUTPUT_NAME "gdi32_mock"
RELEASEINTERNAL_OUTPUT_NAME "gdi32_mock"
OUTPUT_NAME "gdi32_mock"
mock_gdi
PROPERTIES DEBUG_OUTPUT_NAME "gdi32_mock"
RELEASE_OUTPUT_NAME "gdi32_mock"
RELEASEINTERNAL_OUTPUT_NAME "gdi32_mock"
OUTPUT_NAME "gdi32_mock"
)
source_group("source files" FILES ${IGDRCL_SRCS_tests_mock_gdi})
create_project_source_tree(mock_gdi)
set_target_properties(mock_gdi PROPERTIES FOLDER "test mocks")

View File

@@ -71,6 +71,8 @@ endif()
add_library(igdrcl_mocks STATIC ${IGDRCL_SRCS_tests_mocks})
create_project_source_tree(igdrcl_mocks)
add_dependencies(igdrcl_mocks gtest gmock)
target_include_directories(igdrcl_mocks PRIVATE

View File

@@ -122,18 +122,7 @@ add_custom_target(run_mt_unit_tests)
add_dependencies(igdrcl_mt_tests test_dynamic_lib)
source_group("source files" FILES ${IGDRCL_SRCS_mt_tests_local})
source_group("source files\\api" FILES ${IGDRCL_SRCS_mt_tests_api})
source_group("source files\\command_queue" FILES ${IGDRCL_SRCS_mt_tests_command_queue})
source_group("source files\\device_queue" FILES ${IGDRCL_SRCS_mt_tests_device_queue})
source_group("source files\\event" FILES ${IGDRCL_SRCS_mt_tests_event})
source_group("source files\\fixtures" FILES ${IGDRCL_SRCS_mt_tests_fixtures})
source_group("source files\\helpers" FILES ${IGDRCL_SRCS_mt_tests_helpers})
source_group("source files\\indirect_heap" FILES ${IGDRCL_SRCS_mt_tests_indirect_heap})
source_group("source files\\memory_manager" FILES ${IGDRCL_SRCS_mt_tests_memory_manager})
source_group("source files\\os_interface" FILES ${IGDRCL_SRCS_mt_tests_os_interface})
source_group("source files\\platform" FILES ${IGDRCL_SRCS_mt_tests_platform})
source_group("source files\\utilities" FILES ${IGDRCL_SRCS_mt_tests_utilities})
create_project_source_tree(igdrcl_mt_tests ${IGDRCL_SOURCE_DIR}/runtime ${IGDRCL_SOURCE_DIR}/unit_tests)
set_target_properties(igdrcl_mt_tests PROPERTIES FOLDER "opencl runtime")
set_property(TARGET igdrcl_mt_tests APPEND_STRING PROPERTY COMPILE_FLAGS ${TSAN_FLAGS})

View File

@@ -84,10 +84,7 @@ if(WIN32)
target_include_directories(cloc_tests PRIVATE ${UMKM_SHAREDDATA_INCLUDE_PATHS})
endif()
# The following filters are added to the VS IDE representation
source_group("source files" FILES ${IGDRCL_SRCS_offline_compiler_tests})
source_group("source files\\windows" FILES ${IGDRCL_SRCS_offline_compiler_tests_windows})
source_group("source files\\mock" FILES ${IGDRCL_SRCS_offline_compiler_mock})
create_project_source_tree(cloc_tests ${IGDRCL_SOURCE_DIR}/runtime ${IGDRCL_SOURCE_DIR}/unit_tests ${IGDRCL_SOURCE_DIR})
set_target_properties(cloc_tests PROPERTIES FOLDER "offline_compiler")
set_property(TARGET cloc_tests APPEND_STRING PROPERTY COMPILE_FLAGS ${ASAN_FLAGS})

View File

@@ -56,6 +56,8 @@ target_include_directories(igdrcl_tbx_tests PRIVATE
${IGDRCL__IGC_INCLUDE_DIR}
)
create_project_source_tree(igdrcl_tbx_tests ${IGDRCL_SOURCE_DIR}/runtime ${IGDRCL_SOURCE_DIR}/unit_tests)
add_custom_target(run_tbx_tests ALL DEPENDS igdrcl_tbx_tests)
add_custom_command(
TARGET run_tbx_tests

View File

@@ -1,4 +1,4 @@
# Copyright (c) 2017, Intel Corporation
# Copyright (c) 2017 - 2018, Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
@@ -18,18 +18,18 @@
# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
# OTHER DEALINGS IN THE SOFTWARE.
cmake_minimum_required(VERSION 3.2.0 FATAL_ERROR)
project(test_dynamic_lib)
if(WIN32)
set(OS_SUFFIX win)
else(WIN32)
else()
set(OS_SUFFIX lin)
endif(WIN32)
endif()
add_library(test_dynamic_lib SHARED test_dynamic_lib_${OS_SUFFIX}.cpp)
create_project_source_tree(test_dynamic_lib)
set_target_properties(test_dynamic_lib PROPERTIES FOLDER "test mocks")
set_property(TARGET test_dynamic_lib APPEND_STRING PROPERTY COMPILE_FLAGS ${ASAN_FLAGS})