Skip to content

Commit

Permalink
CMake: Remove find_package hack and change thirdparty layout
Browse files Browse the repository at this point in the history
  • Loading branch information
KerstinKeller committed Nov 14, 2023
1 parent ffc16d8 commit dde6557
Show file tree
Hide file tree
Showing 89 changed files with 174 additions and 124 deletions.
36 changes: 18 additions & 18 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
[submodule "thirdparty/protobuf"]
path = thirdparty/protobuf
path = thirdparty/protobuf/protobuf
url = https://github.com/protocolbuffers/protobuf.git
[submodule "thirdparty/asio"]
path = thirdparty/asio
path = thirdparty/asio/asio
url = https://github.com/chriskohlhoff/asio.git
[submodule "thirdparty/tclap"]
path = thirdparty/tclap
path = thirdparty/tclap/tclap
url = https://github.com/xguerin/tclap.git
[submodule "thirdparty/simpleini"]
path = thirdparty/simpleini
path = thirdparty/simpleini/simpleini
url = https://github.com/brofield/simpleini.git
[submodule "thirdparty/spdlog"]
path = thirdparty/spdlog
path = thirdparty/spdlog/spdlog
url = https://github.com/gabime/spdlog.git
[submodule "thirdparty/googletest"]
path = thirdparty/googletest
path = thirdparty/gtest/googletest
url = https://github.com/google/googletest.git
[submodule "thirdparty/fineftp-server"]
path = thirdparty/fineftp-server
path = thirdparty/fineftp/fineftp-server
url = https://github.com/eclipse-ecal/fineftp-server.git
[submodule "thirdparty/tinyxml2"]
path = thirdparty/tinyxml2
path = thirdparty/tinyxml2/tinyxml2
url = https://github.com/leethomason/tinyxml2
[submodule "thirdparty/curl"]
path = thirdparty/curl
path = thirdparty/curl/curl
url = https://github.com/curl/curl.git
[submodule "thirdparty/zlib"]
path = thirdparty/zlib
path = thirdparty/zlib/zlib
url = https://github.com/madler/zlib.git
[submodule "thirdparty/libssh2"]
path = thirdparty/libssh2
path = thirdparty/libssh2/libssh2
url = https://github.com/libssh2/libssh2.git
[submodule "thirdparty/hdf5"]
path = thirdparty/hdf5
path = thirdparty/hdf5/hdf5
url = https://github.com/HDFGroup/hdf5.git
[submodule "thirdparty/termcolor"]
path = thirdparty/termcolor
path = thirdparty/termcolor/termcolor
url = https://github.com/ikalnytskyi/termcolor.git
[submodule "thirdparty/recycle"]
path = thirdparty/recycle
path = thirdparty/recycle/recycle
url = https://github.com/steinwurf/recycle.git
[submodule "thirdparty/tcp_pubsub"]
path = thirdparty/tcp_pubsub
path = thirdparty/tcp_pubsub/tcp_pubsub
url = https://github.com/eclipse-ecal/tcp_pubsub.git
[submodule "thirdparty/qwt/qwt"]
path = thirdparty/qwt/qwt
url = https://git.code.sf.net/p/qwt/git
[submodule "thirdparty/yaml-cpp"]
path = thirdparty/yaml-cpp
path = thirdparty/yaml-cpp/yaml-cpp
url = https://github.com/jbeder/yaml-cpp.git
[submodule "thirdparty/ftxui"]
path = thirdparty/ftxui
path = thirdparty/ftxui/ftxui
url = https://github.com/ArthurSonzogni/FTXUI.git
[submodule "thirdparty/udpcap"]
path = thirdparty/udpcap
path = thirdparty/udpcap/udpcap
url = https://github.com/eclipse-ecal/udpcap.git
107 changes: 51 additions & 56 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
cmake_minimum_required(VERSION 3.13)

include(CMakeDependentOption)
include("${CMAKE_CURRENT_LIST_DIR}/thirdparty/cmake_functions/qt/qt_msvc_path.cmake")

if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW) # Prevent HDF5 from overwriting our output paths
Expand Down Expand Up @@ -91,17 +90,20 @@ option(ECAL_NPCAP_SUPPORT "Enable the eCAL Npcap Receiver (
option(ECAL_USE_CLOCKLOCK_MUTEX "Use native mutex with monotonic clock (requires glibc >= 2.30)" OFF)

# Set option regarding third party library builds
# option(ECAL_THIRDPARTY_BUILD_LIBSSH2 "Build libssh2 with eCAL" ON)
# option(ECAL_THIRDPARTY_BUILD_ZLIB "Build zlib with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_ASIO "Build asio with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_CMAKE_FUNCTIONS "Build CMakeFunctions with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_SPDLOG "Build spdlog with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_TINYXML2 "Build tinyxml2 with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_FINEFTP "Build fineFTP with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_TERMCOLOR "Build termcolor with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_TCP_PUBSUB "Build tcp_pubsub library with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_RECYCLE "Build steinwurf::recylce with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_FTXUI "Build ftxui with eCAL" ON)
# option(ECAL_THIRDPARTY_BUILD_ZLIB "Build zlib with eCAL" ON)
# option(ECAL_THIRDPARTY_BUILD_LIBSSH2 "Build libssh2 with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_GTEST "Build gtest with eCAL" OFF)
option(ECAL_THIRDPARTY_BUILD_RECYCLE "Build steinwurf::recylce with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_SPDLOG "Build spdlog with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_SIMPLEINI "Build simpleini with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_TCLAP "Build tclap library with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_TCP_PUBSUB "Build tcp_pubsub library with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_TERMCOLOR "Build termcolor with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_TINYXML2 "Build tinyxml2 with eCAL" ON)
option(ECAL_THIRDPARTY_BUILD_UDPCAP "Build udpcap library with eCAL" OFF)

if(WIN32)
Expand Down Expand Up @@ -165,65 +167,41 @@ if(MSVC)
endif()
endif()

# --------------------------------------------------------
# detect qt library
# --------------------------------------------------------
if(MSVC)
if (HAS_QT5)
find_package(Qt5 COMPONENTS Core QUIET)
if (NOT "${Qt5_FOUND}")
autodetect_qt5_msvc_dir()
endif()
endif()
endif()

# This is a list of subprojects, that might be build with eCAL
# according to how options ECAL_BUILD_<SUBPROJECT> are set
set(possible_subprojects
Protobuf
spdlog
tinyxml2
fineftp
termcolor
recycle
tcp_pubsub
#libssh2
#zlib zlibstatic
asio
CMakeFunctions
CURL
fineftp
ftxui
GTest
HDF5
CMakeFunctions
#libssh2
Protobuf
qwt
yaml-cpp
ftxui
recycle
simpleini
spdlog
tclap
tcp_pubsub
termcolor
tinyxml2
udpcap
yaml-cpp
#zlib zlibstatic
)

# We should rename the option, but don't know how to do in in a
# backwards compatible way
set(ECAL_THIRDPARTY_BUILD_CMAKEFUNCTIONS ${ECAL_THIRDPARTY_BUILD_CMAKE_FUNCTIONS})

# For each dependency, check if option to build was set or not
# if so append to `as_subproject` list
foreach (dep IN LISTS possible_subprojects)
string(TOUPPER ${dep} dep_upper)
if (ECAL_THIRDPARTY_BUILD_${dep_upper})
list(APPEND as_subproject ${dep})
endif ()
endforeach()

macro(find_package)
if(NOT "${ARGV0}" IN_LIST as_subproject)
_find_package(${ARGV})
endif()
endmacro()

# if a package does need to be build, include the cmake file with build instructions
foreach (dep IN LISTS possible_subprojects)
string(TOUPPER ${dep} dep_upper)
string(TOLOWER ${dep} dep_lower)
if (ECAL_THIRDPARTY_BUILD_${dep_upper})
include(thirdparty/build-${dep_lower}.cmake)
include(thirdparty/${dep_lower}/build-${dep_lower}.cmake)
endif ()
endforeach ()

Expand All @@ -234,6 +212,19 @@ endif()

find_package(CMakeFunctions REQUIRED)

# --------------------------------------------------------
# detect qt library
# --------------------------------------------------------
if(MSVC)
if (HAS_QT5)
find_package(Qt5 COMPONENTS Core QUIET)
if (NOT "${Qt5_FOUND}")
autodetect_qt5_msvc_dir()
endif()
endif()
endif()


git_revision_information(DEFAULT ${ECAL_BUILD_VERSION})
set(eCAL_VERSION_MAJOR ${GIT_REVISION_MAJOR})
set(eCAL_VERSION_MINOR ${GIT_REVISION_MINOR})
Expand Down Expand Up @@ -574,20 +565,24 @@ message(STATUS "ECAL_INCLUDE_PY_SAMPLES : ${ECAL_INCLUDE_
message(STATUS "ECAL_INSTALL_SAMPLE_SOURCES : ${ECAL_INSTALL_SAMPLE_SOURCES}")
message(STATUS "ECAL_JOIN_MULTICAST_TWICE : ${ECAL_JOIN_MULTICAST_TWICE}")
message(STATUS "ECAL_NPCAP_SUPPORT : ${ECAL_NPCAP_SUPPORT}")
message(STATUS "ECAL_THIRDPARTY_BUILD_ASIO : ${ECAL_THIRDPARTY_BUILD_ASIO}")
message(STATUS "ECAL_THIRDPARTY_BUILD_CMAKE_FUNCTIONS : ${ECAL_THIRDPARTY_BUILD_CMAKE_FUNCTIONS}")
message(STATUS "ECAL_THIRDPARTY_BUILD_SPDLOG : ${ECAL_THIRDPARTY_BUILD_SPDLOG}")
message(STATUS "ECAL_THIRDPARTY_BUILD_TINYXML2 : ${ECAL_THIRDPARTY_BUILD_TINYXML2}")
message(STATUS "ECAL_THIRDPARTY_BUILD_CURL : ${ECAL_THIRDPARTY_BUILD_CURL}")
message(STATUS "ECAL_THIRDPARTY_BUILD_FINEFTP : ${ECAL_THIRDPARTY_BUILD_FINEFTP}")
message(STATUS "ECAL_THIRDPARTY_BUILD_TERMCOLOR : ${ECAL_THIRDPARTY_BUILD_TERMCOLOR}")
message(STATUS "ECAL_THIRDPARTY_BUILD_TCP_PUBSUB : ${ECAL_THIRDPARTY_BUILD_TCP_PUBSUB}")
message(STATUS "ECAL_THIRDPARTY_BUILD_RECYCLE : ${ECAL_THIRDPARTY_BUILD_RECYCLE}")
message(STATUS "ECAL_THIRDPARTY_BUILD_FTXUI : ${ECAL_THIRDPARTY_BUILD_FTXUI}")
message(STATUS "ECAL_THIRDPARTY_BUILD_GTEST : ${ECAL_THIRDPARTY_BUILD_GTEST}")
message(STATUS "ECAL_THIRDPARTY_BUILD_PROTOBUF : ${ECAL_THIRDPARTY_BUILD_PROTOBUF}")
message(STATUS "ECAL_THIRDPARTY_BUILD_CURL : ${ECAL_THIRDPARTY_BUILD_CURL}")
message(STATUS "ECAL_THIRDPARTY_BUILD_HDF5 : ${ECAL_THIRDPARTY_BUILD_HDF5}")
message(STATUS "ECAL_THIRDPARTY_BUILD_YAML-CPP : ${ECAL_THIRDPARTY_BUILD_YAML-CPP}")
message(STATUS "ECAL_THIRDPARTY_BUILD_PROTOBUF : ${ECAL_THIRDPARTY_BUILD_PROTOBUF}")
message(STATUS "ECAL_THIRDPARTY_BUILD_QWT : ${ECAL_THIRDPARTY_BUILD_QWT}")
message(STATUS "ECAL_THIRDPARTY_BUILD_RECYCLE : ${ECAL_THIRDPARTY_BUILD_RECYCLE}")
message(STATUS "ECAL_THIRDPARTY_BUILD_SIMPLEINI : ${ECAL_THIRDPARTY_BUILD_SIMPLEINI}")
message(STATUS "ECAL_THIRDPARTY_BUILD_SPDLOG : ${ECAL_THIRDPARTY_BUILD_SPDLOG}")
message(STATUS "ECAL_THIRDPARTY_BUILD_TCLAP : ${ECAL_THIRDPARTY_BUILD_TCLAP}")
message(STATUS "ECAL_THIRDPARTY_BUILD_TCP_PUBSUB : ${ECAL_THIRDPARTY_BUILD_TCP_PUBSUB}")
message(STATUS "ECAL_THIRDPARTY_BUILD_TERMCOLOR : ${ECAL_THIRDPARTY_BUILD_TERMCOLOR}")
message(STATUS "ECAL_THIRDPARTY_BUILD_TINYXML2 : ${ECAL_THIRDPARTY_BUILD_TINYXML2}")
message(STATUS "ECAL_THIRDPARTY_BUILD_UDPCAP : ${ECAL_THIRDPARTY_BUILD_UDPCAP}")
message(STATUS "ECAL_THIRDPARTY_BUILD_YAML-CPP : ${ECAL_THIRDPARTY_BUILD_YAML-CPP}")
message(STATUS "ECAL_LINK_HDF5_SHARED : ${ECAL_LINK_HDF5_SHARED}")
message(STATUS "CPACK_PACK_WITH_INNOSETUP : ${CPACK_PACK_WITH_INNOSETUP}")

Expand Down
5 changes: 0 additions & 5 deletions cmake/Modules/Findasio.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
find_path(asio_INCLUDE_DIR
NAMES asio.hpp
HINTS
"${CONAN_ASIO_ROOT}/include"
"${ECAL_PROJECT_ROOT}/thirdparty/asio/asio/include"
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH
)

if(asio_INCLUDE_DIR-NOTFOUND)
Expand Down
1 change: 1 addition & 0 deletions cmake/Modules/FindeCAL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(eCAL_FOUND TRUE)
5 changes: 0 additions & 5 deletions cmake/Modules/Findsimpleini.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
find_path(simpleini_INCLUDE_DIR
NAMES SimpleIni.h
HINTS
"${CONAN_SIMPLEINI_ROOT}/include"
"${ECAL_PROJECT_ROOT}/thirdparty/simpleini"
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH
)

if(simpleini_INCLUDE_DIR-NOTFOUND)
Expand Down
5 changes: 0 additions & 5 deletions cmake/Modules/Findtclap.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
find_path(tclap_INCLUDE_DIR
NAMES tclap/Arg.h
HINTS
"${CONAN_TCLAP_ROOT}/include"
"${ECAL_PROJECT_ROOT}/thirdparty/tclap/include"
NO_DEFAULT_PATH
NO_CMAKE_FIND_ROOT_PATH
)

if(tclap_INCLUDE_DIR-NOTFOUND)
Expand Down
1 change: 1 addition & 0 deletions thirdparty/asio/Modules/Findasio.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(asio_FOUND TRUE)
5 changes: 5 additions & 0 deletions thirdparty/asio/build-asio.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
add_library(asio::asio INTERFACE IMPORTED)
target_include_directories(asio::asio INTERFACE thirdparty/asio/asio/asio/include)
target_compile_definitions(asio::asio INTERFACE ASIO_STANDALONE)

list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Modules)
Empty file removed thirdparty/build-asio.cmake
Empty file.
1 change: 0 additions & 1 deletion thirdparty/build-cmakefunctions.cmake

This file was deleted.

3 changes: 0 additions & 3 deletions thirdparty/build-fineftp.cmake

This file was deleted.

4 changes: 0 additions & 4 deletions thirdparty/build-libssh2.cmake

This file was deleted.

1 change: 0 additions & 1 deletion thirdparty/build-qwt.cmake

This file was deleted.

2 changes: 0 additions & 2 deletions thirdparty/build-recycle.cmake

This file was deleted.

Empty file removed thirdparty/build-simpleini.cmake
Empty file.
Empty file removed thirdparty/build-tclap.cmake
Empty file.
3 changes: 0 additions & 3 deletions thirdparty/build-tcp_pubsub.cmake

This file was deleted.

1 change: 0 additions & 1 deletion thirdparty/build-termcolor.cmake

This file was deleted.

3 changes: 0 additions & 3 deletions thirdparty/build-zlib.cmake

This file was deleted.

1 change: 1 addition & 0 deletions thirdparty/cmakefunctions/Modules/FindCMakeFunctions.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(CMakeFunctions_FOUND TRUE)
2 changes: 2 additions & 0 deletions thirdparty/cmakefunctions/build-cmakefunctions.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
add_subdirectory(thirdparty/cmakefunctions/cmake_functions)
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Modules)
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions thirdparty/curl/Modules/FindCURL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(CURL_FOUND TRUE)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ endif()
set(BUILD_CURL_EXE OFF CACHE BOOL "Don't build the curl executable" FORCE)
set(ENABLE_MANUAL OFF CACHE BOOL "Disable built-in manual" FORCE)

add_subdirectory(thirdparty/curl EXCLUDE_FROM_ALL)
add_subdirectory(thirdparty/curl/curl EXCLUDE_FROM_ALL)

if (NOT TARGET CURL::libcurl)
add_library(CURL::libcurl ALIAS libcurl)
Expand All @@ -18,3 +18,5 @@ if (NOT TARGET CURL::libcurl)
)
endif()
endif()

list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Modules)
1 change: 1 addition & 0 deletions thirdparty/fineftp/Modules/Findfineftp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(fineftp_FOUND TRUE)
5 changes: 5 additions & 0 deletions thirdparty/fineftp/build-fineftp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
add_subdirectory(thirdparty/fineftp/fineftp-server/fineftp-server EXCLUDE_FROM_ALL)
set_property(TARGET server PROPERTY FOLDER lib/fineftp)
add_library(fineftp::server ALIAS server)

list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Modules)
1 change: 1 addition & 0 deletions thirdparty/ftxui/Modules/Findftxui.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(ftxui_FOUND TRUE)
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
option(FTXUI_BUILD_EXAMPLES "Set to ON to build examples" OFF)

add_subdirectory(thirdparty/ftxui EXCLUDE_FROM_ALL)
add_subdirectory(thirdparty/ftxui/ftxui EXCLUDE_FROM_ALL)

# Set ftxui_VERSION_MAJOR, because it's only defined in the subdirectory scope and we cannot access it
# Reading it automatically is less error prone than setting itt by hand
file(READ thirdparty/ftxui/CMakeLists.txt content)
file(READ thirdparty/ftxui/ftxui/CMakeLists.txt content)
if(content MATCHES "VERSION ([0-9]+)\\.[0-9]+\\.[0-9]+")
set(ftxui_VERSION_MAJOR "${CMAKE_MATCH_1}")
else()
message(FATAL_ERROR "Couldn't read version info")
endif()
endif()

list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/Modules)
1 change: 1 addition & 0 deletions thirdparty/gtest/Modules/FindGTest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(GTest_FOUND TRUE)
Loading

0 comments on commit dde6557

Please sign in to comment.