-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
75 lines (56 loc) · 2.66 KB
/
CMakeLists.txt
File metadata and controls
75 lines (56 loc) · 2.66 KB
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
######### CMake Version ###################################
cmake_minimum_required(VERSION 2.8.11)
###########################################################
######### Info ############################################
message( STATUS ">> CMAKE_C_COMPILER: ${CMAKE_C_COMPILER}" )
message( STATUS ">> CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}" )
###########################################################
######### Project Name ####################################
project( exceptions )
set( LIBRARY_NAME mylib )
set( EXECUTABLE_NAME run )
###########################################################
######### Have the binary placed into the source head #####
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR} )
### Output paths for multi-config builds (e.g. msvc)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_SOURCE_DIR} )
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
###########################################################
######### Prevent messing up the source tree ##############
set( CMAKE_DISABLE_SOURCE_CHANGES ON )
set( CMAKE_DISABLE_IN_SOURCE_BUILD ON )
###########################################################
######### Library #########################################
set(MYLIB_HEADER_FILES
include/API.hpp
include/detail/Library.hpp
include/detail/Exception.hpp
)
set(MYLIB_SOURCE_FILES
src/API.cpp
src/detail/Library.cpp
src/detail/Exception.cpp
)
add_library( ${LIBRARY_NAME} ${MYLIB_SOURCE_FILES} )
set_target_properties( ${LIBRARY_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF )
target_include_directories( ${LIBRARY_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include)
target_include_directories( ${LIBRARY_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/thirdparty)
target_compile_options( ${LIBRARY_NAME} PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Werror -Wall -Wextra -Wpedantic -pedantic-errors -Wconversion -Wsign-conversion >
$<$<CXX_COMPILER_ID:MSVC>:
/WX /W4 >)
###########################################################
######### Executable ######################################
add_executable( ${EXECUTABLE_NAME} main.cpp )
set_target_properties( ${EXECUTABLE_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF )
target_link_libraries( ${EXECUTABLE_NAME} PUBLIC mylib)
###########################################################