-
Notifications
You must be signed in to change notification settings - Fork 1
/
source_group.cmake
59 lines (54 loc) · 1.91 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 <[email protected]>
# Homepage: https://github.com/zchrissirhcz/cmake_tools
# Last update: 2024-05-26 23:30:00
cmake_minimum_required(VERSION 3.15)
include_guard()
# --[ correctly show folder structure in Visual Studio
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(assign_source_group)
function(overlook_add_executable)
if (CMAKE_SYSTEM_NAME MATCHES "Windows" OR CMAKE_SYSTEM_NAME MATCHES "Darwin")
foreach(_source IN ITEMS ${ARGN})
assign_source_group(${_source})
endforeach()
#message("${ARGV}")
endif ()
add_executable(${ARGV})
endfunction(overlook_add_executable)
function(overlook_cuda_add_executable)
if (CMAKE_SYSTEM_NAME MATCHES "Windows" OR CMAKE_SYSTEM_NAME MATCHES "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" OR CMAKE_SYSTEM_NAME MATCHES "Darwin")
foreach(_source IN ITEMS ${ARGN})
assign_source_group(${_source})
endforeach()
#message("${ARGV}")
endif ()
add_library(${ARGV})
endfunction(overlook_add_library)
function(overlook_cuda_add_library)
if (CMAKE_SYSTEM_NAME MATCHES "Windows" OR CMAKE_SYSTEM_NAME MATCHES "Darwin")
foreach(_source IN ITEMS ${ARGN})
assign_source_group(${_source})
endforeach()
#message("${ARGV}")
endif ()
cuda_add_library(${ARGV})
endfunction(overlook_cuda_add_library)