67 lines
1.9 KiB
CMake
67 lines
1.9 KiB
CMake
#################### CONFIGURATION ######################
|
|
set(OUTPUT_PATH bin)
|
|
set(LIB_DIR lib)
|
|
set(DEFAULT_BUILD_TYPE Debug)
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
# Boost configuration
|
|
set(BOOST_COMPONENTS program_options)
|
|
|
|
###################### START_CMAKE #######################
|
|
cmake_minimum_required(VERSION 3.9.1)
|
|
project(FlippR-Driver VERSION 0.1.0 LANGUAGES CXX)
|
|
|
|
# Compile library to output_path
|
|
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/${OUTPUT_PATH})
|
|
|
|
|
|
|
|
# Default to Release build
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE ${DEFAULT_BUILD_TYPE})
|
|
endif(NOT CMAKE_BUILD_TYPE)
|
|
|
|
option(BUILD_SHARED_LIB "Build a shared lib instead of a static." OFF)
|
|
option(ENABLE_TESTING "Enables testing." OFF)
|
|
|
|
#################### Adding Library #####################
|
|
file(GLOB_RECURSE SOURCES src/*.cpp)
|
|
|
|
if(BUILD_SHARED_LIB)
|
|
add_library(${PROJECT_NAME} SHARED ${SOURCES})
|
|
else()
|
|
add_library(${PROJECT_NAME} STATIC ${SOURCES})
|
|
endif(BUILD_SHARED_LIB)
|
|
|
|
######################### BOOST #########################
|
|
find_package(Boost REQUIRED COMPONENTS ${BOOST_COMPONENTS})
|
|
if(Boost_FOUND)
|
|
# Include and link with boost
|
|
target_include_directories(${PROJECT_NAME} PUBLIC ${Boost_INCLUDE_DIRS})
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${Boost_LIBRARIES})
|
|
message ("Boost found and linked.")
|
|
else()
|
|
message (FATAL_ERROR "Can't find Boost.")
|
|
endif(Boost_FOUND)
|
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/src)
|
|
|
|
# Set libraries include path
|
|
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/${LIB_DIR})
|
|
|
|
##################### WIRING_PI ##########################
|
|
find_library(WIRING_PI NAMES libwiringPi.so.2.44 HINTS ${CMAKE_SOURCE_DIR}/lib)
|
|
|
|
if(NOT WIRING_PI)
|
|
message(FATAL_ERROR "Could not find wiringPi library")
|
|
endif()
|
|
|
|
target_link_libraries(${PROJECT_NAME} PUBLIC ${WIRING_PI})
|
|
|
|
|
|
if(ENABLE_TESTING)
|
|
add_subdirectory(tests)
|
|
endif(ENABLE_TESTING)
|
|
####################### END_CMAKE ########################
|