Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 41 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.1)
project(modbuspp)
project(modbuspp VERSION 1.0.0)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually version # > 1.0 means it is safe to enter production. I would following the release version to be 0.3

set(CMAKE_CXX_STANDARD 11)


Expand All @@ -10,19 +10,45 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
endif()

# BUILD INTERFACE LIB
install(FILES
"modbus.h"
DESTINATION
include/modbuspp
add_library(modbuspp_lib INTERFACE)
target_include_directories(modbuspp_lib INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/modbus.h>
$<INSTALL_INTERFACE:include>
)

include(CMakePackageConfigHelpers)
install(TARGETS modbuspp_lib
EXPORT modbusppTargets
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
PUBLIC_HEADER DESTINATION include )

write_basic_package_version_file("modbusppConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)

configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/modbusppConfig.cmake.in"
"${PROJECT_BINARY_DIR}/modbusppConfig.cmake"
INSTALL_DESTINATION lib/cmake/modbuspp
)
install(EXPORT modbusppTargets DESTINATION lib/cmake/modbuspp)
install(FILES "${PROJECT_BINARY_DIR}/modbusppConfigVersion.cmake"
"${PROJECT_BINARY_DIR}/modbusppConfig.cmake"
DESTINATION lib/cmake/modbuspp)
install(FILES ${PROJECT_SOURCE_DIR}/modbus.h DESTINATION include)

# BUILD EXAMPLE
set(EXAMPLE_FILES example/example.cpp)
add_executable(modbuspp_example ${EXAMPLE_FILES})
target_compile_definitions(modbuspp_example
PUBLIC
ENABLE_MODBUSPP_LOGGING
)
target_include_directories(modbuspp_example
PUBLIC
.
)
IF(BUILD_EXAMPLE)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please update the README?

set(EXAMPLE_FILES example/example.cpp)
add_executable(modbuspp_example ${EXAMPLE_FILES})
target_compile_definitions(modbuspp_example
PUBLIC
ENABLE_MODBUSPP_LOGGING
)
target_include_directories(modbuspp_example
PUBLIC
.
)
ENDIF()
4 changes: 4 additions & 0 deletions cmake/modbusppConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/modbusppTargets.cmake")
check_required_components("@PROJECT_NAME@")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] please insert a new line