# HG changeset patch # User Hasan Yavuz ÖZDERYA # Date 2017-03-11 10:17:53 # Node ID 38669ef60576f364433466be628f81a0c12f2c2a # Parent c3296528103cb11bfc2a1e4a561f3acf5e243a40 add find script for ledwidget library diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,10 +55,16 @@ else (BUILD_QWT) endif (BUILD_QWT) include(BuildQColorWidgets) -include(BuildLedWidget) + +set(BUILD_LEDWIDGET true CACHE BOOL "Download and build LedWidget automatically.") +if (BUILD_LEDWIDGET) + include(BuildLedWidget) +else (BUILD_LEDWIDGET) + include(FindLedWidget) +endif (BUILD_LEDWIDGET) # includes -include_directories("./src" ${QWT_INCLUDE_DIR} ${QCW_INCLUDE_DIR} ${LEDW_INCLUDE_DIR}) +include_directories("./src" ${QWT_INCLUDE_DIR} ${QCW_INCLUDE_DIR} ${LEDWIDGET_INCLUDE_DIR}) # flags set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${QCW_FLAGS}") @@ -134,13 +140,18 @@ add_executable(${PROGRAM_NAME} WIN32 ) # Use the Widgets module from Qt 5. -target_link_libraries(${PROGRAM_NAME} ${QWT_LIBRARY} ${QCW_LIBRARY} ${LEDW_LIBRARY}) +target_link_libraries(${PROGRAM_NAME} ${QWT_LIBRARY} ${QCW_LIBRARY} ${LEDWIDGET_LIBRARY}) qt5_use_modules(${PROGRAM_NAME} Widgets SerialPort) +# external project dependencies if (BUILD_QWT) - add_dependencies(${PROGRAM_NAME} QWT LEDW) + add_dependencies(${PROGRAM_NAME} QWT) endif (BUILD_QWT) +if (BUILD_LEDWIDGET) + add_dependencies(${PROGRAM_NAME} LEDW) +endif (BUILD_LEDWIDGET) + # set compiler flags set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") diff --git a/cmake/modules/BuildLedWidget.cmake b/cmake/modules/BuildLedWidget.cmake --- a/cmake/modules/BuildLedWidget.cmake +++ b/cmake/modules/BuildLedWidget.cmake @@ -26,6 +26,5 @@ ExternalProject_Add(LEDW INSTALL_COMMAND "") ExternalProject_Get_Property(LEDW binary_dir source_dir) -set(LEDW_INCLUDE_DIR ${source_dir}/src) -message(${LEDW_INCLUDE_DIR}) -set(LEDW_LIBRARY ${binary_dir}/libledwidget.a) +set(LEDWIDGET_INCLUDE_DIR ${source_dir}/src) +set(LEDWIDGET_LIBRARY ${binary_dir}/libledwidget.a) diff --git a/cmake/modules/FindLedWidget.cmake b/cmake/modules/FindLedWidget.cmake new file mode 100644 --- /dev/null +++ b/cmake/modules/FindLedWidget.cmake @@ -0,0 +1,25 @@ +# +# Copyright © 2017 Hasan Yavuz Özderya +# +# This file is part of serialplot. +# +# serialplot is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# serialplot is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with serialplot. If not, see . +# + +find_library(LEDWIDGET_LIBRARY "ledwidget") +find_path(LEDWIDGET_INCLUDE_DIR "ledwidget.h" PATH_SUFFIXES "ledwidget") + +mark_as_advanced(LEDWIDGET_LIBRARY LEDWIDGET_INCLUDE_DIR) + +find_package_handle_standard_args(LedWidget DEFAULT_MSG LEDWIDGET_LIBRARY LEDWIDGET_INCLUDE_DIR)