-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
61 lines (47 loc) · 1.81 KB
/
CMakeLists.txt
File metadata and controls
61 lines (47 loc) · 1.81 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
#============================================================================
# Name : CMakeLists.txt
# Author : Juan Manuel Fernández Muñoz
# Date : July, 2017
# Description : CMake configuration file for ComInterface library
#============================================================================
# CMake minimum required version
cmake_minimum_required(VERSION 2.8)
# Project name
project(cominterface)
# Compile options
if(NOT DEFINED BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON CACHE BOOL
"Compile the library as a shared library." FORCE)
endif(NOT DEFINED BUILD_SHARED_LIBS)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif(NOT CMAKE_BUILD_TYPE)
# Set the output folder where the library will be created
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
# Boost libraries
set(BOOST_LIBS system)
find_package(Boost COMPONENTS ${BOOST_LIBS} REQUIRED)
# Headers
include_directories(${CMAKE_SOURCE_DIR}/include ${Boost_INCLUDE_DIR})
# ComInterface sources
set(LIBRARY_SRC src/comserial.cpp src/comsocket.cpp)
# ComInterface library
add_library(${PROJECT_NAME} ${LIBRARY_SRC})
# Linker libraries
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
if(WIN32)
target_link_libraries(${PROJECT_NAME} ws2_32 wsock32)
endif()
# Installation
install(DIRECTORY include/cominterface/
DESTINATION include/cominterface
FILES_MATCHING PATTERN "*.hpp")
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
# Example
add_subdirectory(example)