-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathCMakeLists.txt
48 lines (38 loc) · 1.46 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
cmake_minimum_required(VERSION 3.5.1)
project(stackvm)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# set this for adding debug symbols
#set (CMAKE_CXX_FLAGS "-pg")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
# Add sources
file(GLOB SOURCES
"${PROJECT_SOURCE_DIR}/src/*.cpp"
)
# Will add __FILENAME__ macros for all source files, which is the filename without full find_path
# Courtesy of SO
function(define_file_basename_for_sources targetname)
get_target_property(source_files "${targetname}" SOURCES)
foreach(sourcefile ${source_files})
# Get source file's current list of compile definitions.
get_property(defs SOURCE "${sourcefile}"
PROPERTY COMPILE_DEFINITIONS)
# Add the FILE_BASENAME=filename compile definition to the list.
get_filename_component(basename "${sourcefile}" NAME)
list(APPEND defs "__FILENAME__=\"${basename}\"")
# Set the updated compile definitions on the source file.
set_property(
SOURCE "${sourcefile}"
PROPERTY COMPILE_DEFINITIONS ${defs})
endforeach()
endfunction()
# Specify include Directory
include_directories(
"${PROJECT_SOURCE_DIR}/include"
)
add_executable(${PROJECT_NAME} ${SOURCES})
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD 17)
set_property(TARGET ${PROJECT_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
define_file_basename_for_sources(${PROJECT_NAME})
install(TARGETS ${PROJECT_NAME} DESTINATION /usr/local/lib)