diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e092b7..42bf469 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ endif() find_package(Qt6 REQUIRED COMPONENTS Widgets Core Test) qt_standard_project_setup() -include(qwt_setup.cmake) +include(QwtConfig.cmake) include(GNUInstallDirs) include(CMakePackageConfigHelpers) diff --git a/QwtConfig.cmake b/QwtConfig.cmake new file mode 100644 index 0000000..6aba2f2 --- /dev/null +++ b/QwtConfig.cmake @@ -0,0 +1,33 @@ +if(MSVC) + set(QWT_BUILD_COMMAND "nmake") +else() + set(QWT_BUILD_COMMAND ${CMAKE_MAKE_PROGRAM}) +endif() + +set(PATCH_MARKER "${CMAKE_CURRENT_BINARY_DIR}/qwt_patch_applied.txt") +if (NOT EXISTS "${PATCH_MARKER}") + set(QWT_PATCH_FILE ${CMAKE_CURRENT_SOURCE_DIR}/qwt.patch) + message(STATUS "Using QWT_PATCH_FILE=${QWT_PATCH_FILE}") + file(TOUCH ${PATCH_MARKER}) +else() + set(QWT_PATCH_FILE ${PATCH_MARKER}) + message(STATUS "Qwt patch already applied. Using empty file as QWT_PATCH_FILE=${PATCH_MARKER}") +endif() + +configure_file(CMakeLists.txt.qwt qwt/CMakeLists.txt) +execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/qwt) +execute_process(COMMAND ${CMAKE_COMMAND} --build . WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/qwt) + +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/qwt/install) +file(COPY ${CMAKE_CURRENT_BINARY_DIR}/qwt/qwt/src/qwt-build/lib DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/qwt/install) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/qwt/install/include) +file(GLOB QWT_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/qwt/qwt/src/qwt/src/*.h") +file(COPY ${QWT_HEADERS} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/qwt/install/include) +set(QWT_INCLUDE_PATH ${CMAKE_CURRENT_BINARY_DIR}/qwt/install/include) +set(QWT_BINARY_PATH ${CMAKE_CURRENT_BINARY_DIR}/qwt/install/lib) + +message(STATUS "Using QWT_INCLUDE_PATH ${QWT_INCLUDE_PATH}") +message(STATUS "Using QWT_BINARY_PATH ${QWT_BINARY_PATH}") + +include_directories(${QWT_INCLUDE_PATH}) +link_directories(${QWT_BINARY_PATH}) diff --git a/qwt_setup.cmake b/qwt_setup.cmake deleted file mode 100644 index 68e2f08..0000000 --- a/qwt_setup.cmake +++ /dev/null @@ -1,40 +0,0 @@ - -cmake_minimum_required(VERSION 3.16) - -function(QWT_SETUP) - if(MSVC) - set(QWT_BUILD_COMMAND "nmake") - else() - set(QWT_BUILD_COMMAND ${CMAKE_MAKE_PROGRAM}) - endif() - - set(PATCH_MARKER "${CMAKE_CURRENT_BINARY_DIR}/qwt_patch_applied.txt") - if (NOT EXISTS "${PATCH_MARKER}") - set(QWT_PATCH_FILE ${CMAKE_CURRENT_SOURCE_DIR}/qwt.patch) - message(STATUS "Using QWT_PATCH_FILE=${QWT_PATCH_FILE}") - file(TOUCH ${PATCH_MARKER}) - else() - set(QWT_PATCH_FILE ${PATCH_MARKER}) - message(STATUS "Qwt patch already applied. Using empty file as QWT_PATCH_FILE=${PATCH_MARKER}") - endif() - - configure_file(CMakeLists.txt.qwt qwt/CMakeLists.txt) - execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/qwt) - execute_process(COMMAND ${CMAKE_COMMAND} --build . WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/qwt) - - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/qwt/install) - file(COPY ${CMAKE_CURRENT_BINARY_DIR}/qwt/qwt/src/qwt-build/lib DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/qwt/install) - file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/qwt/install/include) - file(GLOB QWT_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/qwt/qwt/src/qwt/src/*.h") - file(COPY ${QWT_HEADERS} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/qwt/install/include) - set(QWT_INCLUDE_PATH ${CMAKE_CURRENT_BINARY_DIR}/qwt/install/include) - set(QWT_BINARY_PATH ${CMAKE_CURRENT_BINARY_DIR}/qwt/install/lib) - - message(STATUS "Using QWT_INCLUDE_PATH ${QWT_INCLUDE_PATH}") - message(STATUS "Using QWT_BINARY_PATH ${QWT_BINARY_PATH}") - - include_directories(${QWT_INCLUDE_PATH}) - link_directories(${QWT_BINARY_PATH}) -endfunction() - -qwt_setup()