From efec18499f5a1d70d96bd9a2c717ddf80540c034 Mon Sep 17 00:00:00 2001 From: ccolin Date: Sun, 9 Jan 2022 16:51:59 +0100 Subject: [PATCH] fix compilation i am absolutely filled with anger at how much time this took. stop using build systems other than cmake. stop using cmake as if it was 2004. stop making languages without a proper, standardized and enforced way to package projects. --- Build/.qglviewer.xml | 30 ------------ external/DGtal/CMakeLists.txt | 11 +++-- external/libQGLViewer/CMakeLists.txt | 70 ++++++++++++++++------------ 3 files changed, 46 insertions(+), 65 deletions(-) delete mode 100644 Build/.qglviewer.xml diff --git a/Build/.qglviewer.xml b/Build/.qglviewer.xml deleted file mode 100644 index 3228740..0000000 --- a/Build/.qglviewer.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/external/DGtal/CMakeLists.txt b/external/DGtal/CMakeLists.txt index a0e846b..fe5832a 100644 --- a/external/DGtal/CMakeLists.txt +++ b/external/DGtal/CMakeLists.txt @@ -2,14 +2,15 @@ cmake_minimum_required(VERSION 3.15) include(FetchContent) -set(WITH_QGLVIEWER true) -set(WITH_QT5 true) -set(BUILD_EXAMPLES OFF) +set(WITH_QGLVIEWER true CACHE INTERNAL "") +set(WITH_QT5 true CACHE INTERNAL "") +set(BUILD_EXAMPLES OFF CACHE INTERNAL "") FetchContent_Declare( DGtal URL https://github.com/DGtal-team/DGtal/archive/refs/tags/1.2.tar.gz - URL_HASH MD5=19e443ca4f3927c9b9eff742cdfa138f - DEPENDS libQGLViewer_ep-build) + URL_HASH MD5=19e443ca4f3927c9b9eff742cdfa138f) FetchContent_MakeAvailable(DGtal) + +target_link_libraries(DGtal PRIVATE libQGLViewer) diff --git a/external/libQGLViewer/CMakeLists.txt b/external/libQGLViewer/CMakeLists.txt index 88fe2d7..9528e00 100644 --- a/external/libQGLViewer/CMakeLists.txt +++ b/external/libQGLViewer/CMakeLists.txt @@ -3,39 +3,49 @@ cmake_minimum_required(VERSION 3.15) include(FetchContent) FetchContent_Declare( - libQGLViewer + libQGLViewer_sources URL http://www.libqglviewer.com/src/libQGLViewer-2.7.2.tar.gz - URL_HASH MD5=a9d965d1ce41f7db6b34f440bb74f061 - CONFIGURE_COMMAND "qmake ${CMAKE_CURRENT_SOURCE_DIR}/QGLViewer/QGLViewer.pro" - STEP_TARGETS build - # BUILD_BYPRODUCTS ${CMAKE_CURRENT_SOURCE_DIR}/QGLViewer/libQGLViewer-qt5.so - LOG_DOWNLOAD true - LOG_CONFIGURE true - LOG_BUILD true - LOG_INSTALL true) + URL_HASH MD5=a9d965d1ce41f7db6b34f440bb74f061) -ExternalProject_Get_property(libQGLViewer_ep SOURCE_DIR) -message("libqglviewer_ep src dir: ${SOURCE_DIR}") -ExternalProject_Get_property(libQGLViewer_ep CONFIGURE_COMMAND) -message("libqglviewer_ep configure command: ${CONFIGURE_COMMAND}") -# ExternalProject_Get_property(libQGLViewer_ep BUILD_BYPRODUCTS) -# message("libqglviewer_ep build byproducts: ${BUILD_BYPRODUCTS}") +FetchContent_MakeAvailable(libQGLViewer_sources) +FetchContent_GetProperties( + libQGLViewer_sources + SOURCE_DIR libQGLViewer_SOURCE_DIR + BINARY_DIR libQGLViewer_BINARY_DIR) -set(QGLVIEWER_INCLUDE_DIR - $ - $ - CACHE PATH "") -# # Can't use find_library as the library isn't there at config time -# find_library(QGLVIEWER_LIBRARIES -# NAMES qglviewer-qt4 qglviewer QGLViewer QGLViewer2 QGLViewer-qt5 -# PATHS ${SOURCE_DIR} -# PATH_SUFFIXES QGLViewer QGLViewer/release) -set(QGLVIEWER_LIBRARIES - $ - $ - CACHE FILEPATH "") +find_program(QMAKE qmake) +execute_process( + WORKING_DIRECTORY ${libQGLViewer_BINARY_DIR} + COMMAND "${QMAKE}" "${libQGLViewer_SOURCE_DIR}/QGLViewer/QGLViewer.pro" + COMMAND_ECHO STDERR + OUTPUT_VARIABLE QGLVIEWER_CFG_OUT + ERROR_VARIABLE QGLVIEWER_CFG_OUT + ECHO_OUTPUT_VARIABLE + ECHO_ERROR_VARIABLE + RESULT_VARIABLE QGLVIEWER_CFG_RES) +message("QGLViewer configuration result: ${QGLVIEWER_CFG_RES}") + +find_program(MAKE make) +include(ProcessorCount) +ProcessorCount(NCORES) +execute_process( + WORKING_DIRECTORY ${libQGLViewer_BINARY_DIR} + COMMAND "${MAKE}" "-j${NCORES}" + COMMAND_ECHO STDERR + OUTPUT_VARIABLE QGLVIEWER_BUILD_OUT + ERROR_VARIABLE QGLVIEWER_BUILD_OUT + ECHO_OUTPUT_VARIABLE + ECHO_ERROR_VARIABLE + RESULT_VARIABLE QGLVIEWER_BUILD_RES) +message("QGLViewer build result: ${QGLVIEWER_BUILD_RES}") add_library(libQGLViewer INTERFACE) + +target_include_directories(libQGLViewer INTERFACE ${libQGLViewer_SOURCE_DIR}) + +# QGLViewer moves its build output back to its source dir +find_library(QGLVIEWER_LIBRARIES + NAMES qglviewer-qt4 qglviewer QGLViewer QGLViewer2 QGLViewer-qt5 + PATHS ${libQGLViewer_SOURCE_DIR} + PATH_SUFFIXES QGLViewer QGLViewer/release) target_link_libraries(libQGLViewer INTERFACE ${QGLVIEWER_LIBRARIES}) -add_dependencies(libQGLViewer libQGLViewer_ep-build) -target_include_directories(libQGLViewer INTERFACE ${QGLVIEWER_INCLUDE_DIR})