-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
89 lines (72 loc) · 2.25 KB
/
CMakeLists.txt
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
cmake_minimum_required(VERSION 3.6)
function(make_source_groups _IN_SOURCES _IN_ROOT_DIR _IN_ROOT_GROUP)
foreach(_source IN ITEMS ${${_IN_SOURCES}})
get_filename_component(_source_path "${_source}" PATH)
file(RELATIVE_PATH _source_path_rel "${_IN_ROOT_DIR}" "${_source_path}")
string(REPLACE "/" "\\" _group_path "${_source_path_rel}")
if (_IN_ROOT_GROUP)
set(_group_path ${_IN_ROOT_GROUP}\\${_group_path})
endif()
source_group("${_group_path}" FILES "${_source}")
endforeach()
endfunction(make_source_groups)
project(psd_ockham)
set (TARGET_NAME psd_ockham)
set(CMAKE_CONFIGURATION_TYPES Debug;Release)
#List source directory
set(_src_root_path "${CMAKE_CURRENT_SOURCE_DIR}/src")
file(
GLOB_RECURSE PROJECT_SOURCES
LIST_DIRECTORIES false
"${_src_root_path}/*.c"
"${_src_root_path}/*.h"
)
make_source_groups(PROJECT_SOURCES ${_src_root_path} "")
#Add headers
include_directories(
"src/libpsd/include"
)
if (__APPLE__)
add_defenition(-D__APPLE__)
endif()
#Target
add_executable(${TARGET_NAME} ${PROJECT_SOURCES})
if (WIN32)
set (TARGET_NAME psd_ockham_gui)
set(CMAKE_CONFIGURATION_TYPES Debug;Release)
set(PROJECT_DEFINITIONS _UNICODE UNICODE)
#List source directory
file(
GLOB_RECURSE C_PROJECT_SOURCES
LIST_DIRECTORIES false
"${_src_root_path}/libpsd/*.c"
"${_src_root_path}/libpsd/*.h"
)
make_source_groups(${C_PROJECT_SOURCES} ${_src_root_path})
set(C_PROJECT_SOURCES ${C_PROJECT_SOURCES} ${_src_root_path}/version.h)
source_group("libpsd" FILES ${_src_root_path}/version.h)
set(_src_gui_root_path "${CMAKE_CURRENT_SOURCE_DIR}/src-gui/win")
file(
GLOB_RECURSE CPP_PROJECT_SOURCES
LIST_DIRECTORIES false
"${_src_gui_root_path}/*.cpp"
"${_src_gui_root_path}/*.h"
)
make_source_groups(CPP_PROJECT_SOURCES ${_src_gui_root_path} "src")
#Add headers
include_directories(
"src/libpsd/include"
"src"
)
file(GLOB_RECURSE PROJECT_RESOURCES
LIST_DIRECTORIES false
"${_src_gui_root_path}/*.ico"
"${_src_gui_root_path}/*.rc"
)
make_source_groups(PROJECT_RESOURCES ${_src_gui_root_path} "resources")
#Target
add_executable(${TARGET_NAME} ${C_PROJECT_SOURCES} ${CPP_PROJECT_SOURCES} ${PROJECT_RESOURCES})
set_target_properties(${TARGET_NAME} PROPERTIES
RESOURCE "${PROJECT_RESOURCES}"
LINK_FLAGS "/SUBSYSTEM:WINDOWS")
endif()