2018-03-30 22:17:22 +02:00
|
|
|
cmake_minimum_required(VERSION 3.0)
|
|
|
|
|
2019-08-26 11:31:15 +02:00
|
|
|
project(pigpio LANGUAGES C VERSION 0.71)
|
2018-03-30 22:17:22 +02:00
|
|
|
|
2019-08-26 11:31:15 +02:00
|
|
|
list (APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
|
|
|
|
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
find_package(RT REQUIRED)
|
2018-03-30 22:17:22 +02:00
|
|
|
|
2019-08-26 12:08:08 +02:00
|
|
|
option(BUILD_SHARED_LIBS "Create shared libraries" ON)
|
2018-03-30 22:17:22 +02:00
|
|
|
|
2019-08-26 11:31:15 +02:00
|
|
|
add_compile_options(-Wall)
|
|
|
|
|
2019-07-21 12:09:48 +02:00
|
|
|
# libpigpio.(so|a)
|
|
|
|
add_library(pigpio pigpio.c command.c custom.cext)
|
|
|
|
|
|
|
|
# libpigpiod_if.(so|a)
|
|
|
|
add_library(pigpiod_if pigpiod_if.c command.c)
|
|
|
|
|
|
|
|
# libpigpiod_if2.(so|a)
|
|
|
|
add_library(pigpiod_if2 pigpiod_if2.c command.c)
|
2018-03-30 22:17:22 +02:00
|
|
|
|
|
|
|
# x_pigpio
|
|
|
|
add_executable(x_pigpio x_pigpio.c)
|
2019-08-26 11:31:15 +02:00
|
|
|
target_link_libraries(x_pigpio pigpio RT::RT Threads::Threads)
|
2018-03-30 22:17:22 +02:00
|
|
|
|
|
|
|
# x_pigpiod_if
|
|
|
|
add_executable(x_pigpiod_if x_pigpiod_if.c)
|
2019-08-26 11:36:24 +02:00
|
|
|
target_link_libraries(x_pigpiod_if pigpiod_if RT::RT Threads::Threads)
|
2018-03-30 22:17:22 +02:00
|
|
|
|
|
|
|
# x_pigpiod_if2
|
|
|
|
add_executable(x_pigpiod_if2 x_pigpiod_if2.c)
|
2019-08-26 11:36:24 +02:00
|
|
|
target_link_libraries(x_pigpiod_if2 pigpiod_if2 RT::RT Threads::Threads)
|
2018-03-30 22:17:22 +02:00
|
|
|
|
|
|
|
# pigpiod
|
|
|
|
add_executable(pigpiod pigpiod.c)
|
2019-08-26 11:31:15 +02:00
|
|
|
target_link_libraries(pigpiod pigpio RT::RT Threads::Threads)
|
2018-03-30 22:17:22 +02:00
|
|
|
|
|
|
|
# pigs
|
|
|
|
add_executable(pigs pigs.c command.c)
|
2019-08-26 11:31:15 +02:00
|
|
|
target_link_libraries(pigs Threads::Threads)
|
2018-03-30 22:17:22 +02:00
|
|
|
|
|
|
|
# pig2vcd
|
|
|
|
add_executable(pig2vcd pig2vcd.c command.c)
|
2019-08-26 11:31:15 +02:00
|
|
|
target_link_libraries(pig2vcd Threads::Threads)
|
2018-03-30 22:17:22 +02:00
|
|
|
|
2019-08-26 12:08:08 +02:00
|
|
|
# Configure and install project
|
2019-08-26 11:31:15 +02:00
|
|
|
|
|
|
|
include (GenerateExportHeader)
|
|
|
|
include (CMakePackageConfigHelpers)
|
|
|
|
|
|
|
|
generate_export_header(${PROJECT_NAME})
|
|
|
|
|
2018-03-30 22:17:22 +02:00
|
|
|
install(TARGETS pigpio pigpiod_if pigpiod_if2 pig2vcd pigpiod pigs
|
2019-08-26 11:31:15 +02:00
|
|
|
EXPORT ${PROJECT_NAME}Targets
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
INCLUDES DESTINATION include
|
|
|
|
)
|
|
|
|
|
|
|
|
write_basic_package_version_file(
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
|
|
|
VERSION ${${PROJECT_NAME}_VERSION}
|
|
|
|
COMPATIBILITY AnyNewerVersion
|
|
|
|
)
|
|
|
|
|
|
|
|
export(EXPORT ${PROJECT_NAME}Targets
|
|
|
|
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake"
|
|
|
|
NAMESPACE pigpio::
|
|
|
|
)
|
|
|
|
|
|
|
|
set(ConfigPackageLocation lib/cmake/${PROJECT_NAME})
|
|
|
|
install(EXPORT ${PROJECT_NAME}Targets
|
|
|
|
FILE
|
|
|
|
${PROJECT_NAME}Targets.cmake
|
|
|
|
NAMESPACE
|
|
|
|
pigpio::
|
|
|
|
DESTINATION
|
|
|
|
${ConfigPackageLocation}
|
|
|
|
)
|
|
|
|
|
|
|
|
install(
|
|
|
|
FILES
|
|
|
|
${CMAKE_CURRENT_LIST_DIR}/cmake/${PROJECT_NAME}Config.cmake
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
|
|
|
DESTINATION
|
|
|
|
${ConfigPackageLocation}
|
2018-03-30 22:17:22 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
install(FILES pigpio.h pigpiod_if.h pigpiod_if2.h
|
2019-08-26 11:31:15 +02:00
|
|
|
DESTINATION include
|
2018-03-30 22:17:22 +02:00
|
|
|
PERMISSIONS OWNER_READ OWNER_WRITE
|
|
|
|
GROUP_READ
|
|
|
|
WORLD_READ
|
|
|
|
)
|
|
|
|
|
|
|
|
file(GLOB man_1_SRC "*.1")
|
|
|
|
install(FILES ${man_1_SRC}
|
2019-08-26 11:31:15 +02:00
|
|
|
DESTINATION man/man1
|
2018-03-30 22:17:22 +02:00
|
|
|
PERMISSIONS OWNER_READ OWNER_WRITE
|
|
|
|
GROUP_READ
|
|
|
|
WORLD_READ
|
|
|
|
)
|
|
|
|
|
|
|
|
file(GLOB man_3_SRC "*.3")
|
|
|
|
install(FILES ${man_3_SRC}
|
2019-08-26 11:31:15 +02:00
|
|
|
DESTINATION man/man3
|
2018-03-30 22:17:22 +02:00
|
|
|
PERMISSIONS OWNER_READ OWNER_WRITE
|
|
|
|
GROUP_READ
|
|
|
|
WORLD_READ
|
|
|
|
)
|
|
|
|
|
2019-08-26 12:08:08 +02:00
|
|
|
# Install python modules.
|
2019-08-26 11:31:15 +02:00
|
|
|
find_package(Python COMPONENTS Interpreter QUIET)
|
2018-03-30 22:17:22 +02:00
|
|
|
|
2019-08-26 11:43:07 +02:00
|
|
|
if(Python_FOUND)
|
2019-08-26 12:00:09 +02:00
|
|
|
configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/setup.py.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/setup.py
|
|
|
|
)
|
|
|
|
|
2019-08-26 12:03:31 +02:00
|
|
|
install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/setup.py install)")
|
2019-08-26 11:43:07 +02:00
|
|
|
endif()
|
2019-08-26 11:31:15 +02:00
|
|
|
|
|
|
|
# package project
|
|
|
|
|
|
|
|
include (CPack)
|