-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1428 from fpagliughi/cmake-update
CMake cleanup, bump to v3.5, and submodule improvements
- Loading branch information
Showing
9 changed files
with
1,309 additions
and
1,404 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#******************************************************************************* | ||
# Copyright (c) 2015, 2020 logi.cals GmbH and others | ||
# Copyright (c) 2015, 2023 logi.cals GmbH, Frank Pagliughi <[email protected]> and others | ||
# | ||
# All rights reserved. This program and the accompanying materials | ||
# are made available under the terms of the Eclipse Public License v2.0 | ||
|
@@ -15,107 +15,128 @@ | |
# Genis Riera Perez - Add support for building debian package | ||
#*******************************************************************************/ | ||
|
||
# Note: on OS X you should install XCode and the associated command-line tools | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) | ||
PROJECT("Eclipse Paho C" C) | ||
MESSAGE(STATUS "CMake version: " ${CMAKE_VERSION}) | ||
MESSAGE(STATUS "CMake system name: " ${CMAKE_SYSTEM_NAME}) | ||
project("Eclipse Paho C" | ||
VERSION 1.4.0 | ||
LANGUAGES C | ||
) | ||
|
||
SET(CMAKE_SCRIPTS "${CMAKE_SOURCE_DIR}/cmake") | ||
SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") | ||
message(STATUS "CMake version: " ${CMAKE_VERSION}) | ||
message(STATUS "CMake system name: " ${CMAKE_SYSTEM_NAME}) | ||
|
||
## build settings | ||
set(CMAKE_SCRIPTS "${CMAKE_SOURCE_DIR}/cmake") | ||
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") | ||
|
||
## Project Version | ||
## Previously we read in the version from these files, but now we use the | ||
## CMake project setting. We just make sure the files and CMake match. | ||
file(READ version.major PAHO_VERSION_MAJOR) | ||
file(READ version.minor PAHO_VERSION_MINOR) | ||
file(READ version.patch PAHO_VERSION_PATCH) | ||
SET(CLIENT_VERSION ${PAHO_VERSION_MAJOR}.${PAHO_VERSION_MINOR}.${PAHO_VERSION_PATCH}) | ||
set(CLIENT_VERSION ${PAHO_VERSION_MAJOR}.${PAHO_VERSION_MINOR}.${PAHO_VERSION_PATCH}) | ||
|
||
if(NOT (CLIENT_VERSION VERSION_EQUAL PROJECT_VERSION)) | ||
message(FATAL_ERROR "CMake project version does NOT match. CMake: ${PROJECT_VERSION}, Files: ${CLIENT_VERSION}") | ||
endif() | ||
|
||
INCLUDE(GNUInstallDirs) | ||
include(GNUInstallDirs) | ||
|
||
STRING(TIMESTAMP BUILD_TIMESTAMP UTC) | ||
MESSAGE(STATUS "Timestamp is ${BUILD_TIMESTAMP}") | ||
string(TIMESTAMP BUILD_TIMESTAMP UTC) | ||
message(STATUS "Timestamp is ${BUILD_TIMESTAMP}") | ||
|
||
IF(WIN32) | ||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -DWIN32_LEAN_AND_MEAN) | ||
ELSEIF(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") | ||
ADD_DEFINITIONS(-DOSX) | ||
ENDIF() | ||
if(WIN32) | ||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -DWIN32_LEAN_AND_MEAN) | ||
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") | ||
add_definitions(-DOSX) | ||
endif() | ||
|
||
## build options | ||
SET(PAHO_WITH_SSL FALSE CACHE BOOL "Flag that defines whether to build ssl-enabled binaries too. ") | ||
SET(PAHO_BUILD_SHARED TRUE CACHE BOOL "Build shared library") | ||
SET(PAHO_BUILD_STATIC FALSE CACHE BOOL "Build static library") | ||
SET(PAHO_BUILD_DOCUMENTATION FALSE CACHE BOOL "Create and install the HTML based API documentation (requires Doxygen)") | ||
SET(PAHO_BUILD_SAMPLES FALSE CACHE BOOL "Build sample programs") | ||
SET(PAHO_BUILD_DEB_PACKAGE FALSE CACHE BOOL "Build debian package") | ||
SET(PAHO_ENABLE_TESTING TRUE CACHE BOOL "Build tests and run") | ||
SET(PAHO_ENABLE_CPACK TRUE CACHE BOOL "Enable CPack") | ||
SET(PAHO_HIGH_PERFORMANCE FALSE CACHE BOOL "Disable tracing and heap tracking") | ||
SET(PAHO_USE_SELECT FALSE CACHE BOOL "Revert to select system call instead of poll") | ||
|
||
IF (PAHO_HIGH_PERFORMANCE) | ||
ADD_DEFINITIONS(-DHIGH_PERFORMANCE=1) | ||
ENDIF() | ||
|
||
IF (PAHO_USE_SELECT) | ||
ADD_DEFINITIONS(-DUSE_SELECT=1) | ||
ENDIF() | ||
|
||
IF (NOT PAHO_BUILD_SHARED AND NOT PAHO_BUILD_STATIC) | ||
MESSAGE(FATAL_ERROR "You must set either PAHO_BUILD_SHARED, PAHO_BUILD_STATIC, or both") | ||
ENDIF() | ||
|
||
IF(PAHO_BUILD_DEB_PACKAGE) | ||
set(CMAKE_INSTALL_DOCDIR share/doc/libpaho-mqtt) | ||
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) | ||
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=") | ||
ENDIF() | ||
|
||
ADD_SUBDIRECTORY(src) | ||
IF(PAHO_BUILD_SAMPLES) | ||
ADD_SUBDIRECTORY(src/samples) | ||
ENDIF() | ||
|
||
IF(PAHO_BUILD_DOCUMENTATION) | ||
ADD_SUBDIRECTORY(doc) | ||
ENDIF() | ||
|
||
IF (PAHO_ENABLE_CPACK) | ||
### packaging settings | ||
FILE(GLOB samples "src/samples/*.c") | ||
INSTALL(FILES ${samples} DESTINATION ${CMAKE_INSTALL_DOCDIR}/samples) | ||
|
||
SET(CPACK_PACKAGE_VENDOR "Eclipse Paho") | ||
SET(CPACK_PACKAGE_NAME "Eclipse-Paho-MQTT-C") | ||
INSTALL(FILES CONTRIBUTING.md epl-v20 edl-v10 README.md notice.html DESTINATION ${CMAKE_INSTALL_DOCDIR}) | ||
|
||
IF (WIN32) | ||
SET(CPACK_GENERATOR "ZIP") | ||
ELSEIF(PAHO_BUILD_DEB_PACKAGE) | ||
INSTALL(FILES CONTRIBUTING.md epl-v20 edl-v10 README.md notice.html DESTINATION ${CMAKE_INSTALL_DOCDIR}) | ||
|
||
SET(CPACK_GENERATOR "DEB") | ||
CONFIGURE_FILE(${CMAKE_SCRIPTS}/CPackDebConfig.cmake.in | ||
${CMAKE_BINARY_DIR}/CPackDebConfig.cmake @ONLY) | ||
SET(CPACK_PROJECT_CONFIG_FILE ${CMAKE_BINARY_DIR}/CPackDebConfig.cmake) | ||
ELSE() | ||
SET(CPACK_GENERATOR "TGZ") | ||
ENDIF() | ||
ELSE() | ||
FILE(GLOB samples "src/samples/*.c") | ||
INSTALL(FILES ${samples} DESTINATION ${CMAKE_INSTALL_DOCDIR}) | ||
ENDIF() | ||
|
||
SET(CPACK_PACKAGE_VERSION_MAJOR ${PAHO_VERSION_MAJOR}) | ||
SET(CPACK_PACKAGE_VERSION_MINOR ${PAHO_VERSION_MINOR}) | ||
SET(CPACK_PACKAGE_VERSION_PATCH ${PAHO_VERSION_PATCH}) | ||
INCLUDE(CPack) | ||
|
||
IF(PAHO_ENABLE_TESTING) | ||
ENABLE_TESTING() | ||
INCLUDE_DIRECTORIES(test src) | ||
ADD_SUBDIRECTORY(test) | ||
ELSE() | ||
INCLUDE_DIRECTORIES(src) | ||
ENDIF() | ||
option(PAHO_WITH_SSL "Flag that defines whether to build ssl-enabled binaries too. " FALSE) | ||
option(PAHO_WITH_LIBUUID "Flag that defines whether libuuid or a custom uuid implementation should be used" FALSE) | ||
option(PAHO_BUILD_SHARED "Build shared library" TRUE) | ||
option(PAHO_BUILD_STATIC "Build static library" FALSE) | ||
option(PAHO_BUILD_DOCUMENTATION "Create and install the HTML based API documentation (requires Doxygen)" FALSE) | ||
option(PAHO_BUILD_SAMPLES "Build sample programs" FALSE) | ||
option(PAHO_BUILD_DEB_PACKAGE "Build debian package" FALSE) | ||
option(PAHO_ENABLE_TESTING "Build tests and run" TRUE) | ||
option(PAHO_ENABLE_CPACK "Enable CPack" TRUE) | ||
option(PAHO_HIGH_PERFORMANCE "Disable tracing and heap tracking" FALSE) | ||
option(PAHO_USE_SELECT "Revert to select system call instead of poll" FALSE) | ||
|
||
if(PAHO_HIGH_PERFORMANCE) | ||
add_definitions(-DHIGH_PERFORMANCE=1) | ||
endif() | ||
|
||
if(PAHO_USE_SELECT) | ||
add_definitions(-DUSE_SELECT=1) | ||
endif() | ||
|
||
if(PAHO_WITH_LIBUUID) | ||
add_definitions(-DUSE_LIBUUID=1) | ||
endif() | ||
|
||
if(NOT PAHO_BUILD_SHARED AND NOT PAHO_BUILD_STATIC) | ||
message(FATAL_ERROR "You must set either PAHO_BUILD_SHARED, PAHO_BUILD_STATIC, or both") | ||
endif() | ||
|
||
if(PAHO_BUILD_SAMPLES AND NOT PAHO_WITH_SSL) | ||
message(WARNING "You must build with SSL to build the full set of samples") | ||
endif() | ||
|
||
if(PAHO_BUILD_DEB_PACKAGE) | ||
set(CMAKE_INSTALL_DOCDIR share/doc/libpaho-mqtt) | ||
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS ON) | ||
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=") | ||
endif() | ||
|
||
add_subdirectory(src) | ||
|
||
if(PAHO_BUILD_SAMPLES) | ||
add_subdirectory(src/samples) | ||
endif() | ||
|
||
if(PAHO_BUILD_DOCUMENTATION) | ||
add_subdirectory(doc) | ||
endif() | ||
|
||
if(PAHO_ENABLE_CPACK) | ||
### packaging settings | ||
file(GLOB samples "src/samples/*.c") | ||
install(FILES ${samples} DESTINATION ${CMAKE_INSTALL_DOCDIR}/samples) | ||
|
||
set(CPACK_PACKAGE_VENDOR "Eclipse Paho") | ||
set(CPACK_PACKAGE_NAME "Eclipse-Paho-MQTT-C") | ||
install(FILES CONTRIBUTING.md epl-v20 edl-v10 README.md notice.html DESTINATION ${CMAKE_INSTALL_DOCDIR}) | ||
|
||
if(WIN32) | ||
set(CPACK_GENERATOR "ZIP") | ||
elseif(PAHO_BUILD_DEB_PACKAGE) | ||
install(FILES CONTRIBUTING.md epl-v20 edl-v10 README.md notice.html DESTINATION ${CMAKE_INSTALL_DOCDIR}) | ||
|
||
set(CPACK_GENERATOR "DEB") | ||
configure_file(${CMAKE_SCRIPTS}/CPackDebConfig.cmake.in | ||
${CMAKE_BINARY_DIR}/CPackDebConfig.cmake @ONLY | ||
) | ||
set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_BINARY_DIR}/CPackDebConfig.cmake) | ||
else() | ||
set(CPACK_GENERATOR "TGZ") | ||
endif() | ||
else() | ||
file(GLOB samples "src/samples/*.c") | ||
install(FILES ${samples} DESTINATION ${CMAKE_INSTALL_DOCDIR}) | ||
endif() | ||
|
||
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) | ||
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) | ||
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) | ||
|
||
include(CPack) | ||
|
||
if(PAHO_ENABLE_TESTING) | ||
enable_testing() | ||
include_directories(test src) | ||
add_subdirectory(test) | ||
else() | ||
include_directories(src) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.