-
Notifications
You must be signed in to change notification settings - Fork 1
/
source_group.cmake
59 lines (54 loc) · 1.71 KB
/
source_group.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# Author: Zhuo Zhang <imzhuo@foxmail.com>
# Homepage: https://github.com/zchrissirhcz/rocbuild
# Last update: 2024-11-14 23:10:00
cmake_minimum_required(VERSION 3.15)
include_guard()
# Show folder structure in Visual Studio / Xcode
function(assign_source_group)
foreach(_source IN ITEMS ${ARGN})
if (IS_ABSOLUTE "${_source}")
file(RELATIVE_PATH _source_rel "${CMAKE_CURRENT_SOURCE_DIR}" "${_source}")
else()
set(_source_rel "${_source}")
endif()
get_filename_component(_source_path "${_source_rel}" PATH)
string(REPLACE "/" "\\" _source_path_msvc "${_source_path}")
source_group("${_source_path_msvc}" FILES "${_source}")
endforeach()
endfunction()
function(overlook_add_executable)
if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|Darwin)$")
foreach(_source IN ITEMS ${ARGN})
assign_source_group(${_source})
endforeach()
#message("${ARGV}")
endif ()
add_executable(${ARGV})
endfunction()
function(overlook_cuda_add_executable)
if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|Darwin)$")
foreach(_source IN ITEMS ${ARGN})
assign_source_group(${_source})
endforeach()
#message("${ARGV}")
endif ()
cuda_add_executable(${ARGV})
endfunction(overlook_cuda_add_executable)
function(overlook_add_library)
if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|Darwin)$")
foreach(_source IN ITEMS ${ARGN})
assign_source_group(${_source})
endforeach()
#message("${ARGV}")
endif ()
add_library(${ARGV})
endfunction()
function(overlook_cuda_add_library)
if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|Darwin)$")
foreach(_source IN ITEMS ${ARGN})
assign_source_group(${_source})
endforeach()
#message("${ARGV}")
endif ()
cuda_add_library(${ARGV})
endfunction()