Skip to content

Commit

Permalink
cmake: build qcustomplot as static lib and fix windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
rp- committed Apr 23, 2014
1 parent 9e73f31 commit 0ecff2c
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ endif()

set(ANTLR_DIR libs/antlr-2.7.7)
set(QHEXEDIT_DIR libs/qhexedit)
set(QCUSTOMPLOT_DIR libs/qcustomplot-source)

add_subdirectory(${ANTLR_DIR})
add_subdirectory(${QHEXEDIT_DIR})
add_subdirectory(${QCUSTOMPLOT_DIR})

if(USE_QT5)
find_package(Qt5Widgets REQUIRED)
Expand Down Expand Up @@ -49,7 +51,6 @@ set(SQLB_MOC_HDR
src/sqlitetablemodel.h
src/sqltextedit.h
src/DbStructureModel.h
libs/qcustomplot-source/qcustomplot.h
)

set(SQLB_SRC
Expand All @@ -73,7 +74,6 @@ set(SQLB_SRC
src/DbStructureModel.cpp
src/grammar/Sqlite3Lexer.cpp
src/grammar/Sqlite3Parser.cpp
libs/qcustomplot-source/qcustomplot.cpp
src/main.cpp
)

Expand Down Expand Up @@ -138,19 +138,19 @@ if(WIN32)
ENDIF( MINGW )
endif(WIN32)

include_directories(${CMAKE_CURRENT_BINARY_DIR} ${ANTLR_DIR} ${QHEXEDIT_DIR} src)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${ANTLR_DIR} ${QHEXEDIT_DIR} ${QCUSTOMPLOT_DIR} src)

add_executable(${PROJECT_NAME} ${SQLB_HDR} ${SQLB_SRC} ${SQLB_FORM_HDR} ${SQLB_MOC} ${SQLB_RESOURCES_RCC})

if(USE_QT5)
qt5_use_modules(${PROJECT_NAME} Gui Widgets PrintSupport Network Test)
qt5_use_modules(${PROJECT_NAME} Gui Widgets Network Test)
set(QT_LIBRARIES "")
endif()
add_dependencies(${PROJECT_NAME} antlr qhexedit)
add_dependencies(${PROJECT_NAME} antlr qhexedit qcustomplot)

link_directories(${CMAKE_CURRENT_BINARY_DIR}/${ANTLR_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${QHEXEDIT_DIR})
link_directories(${CMAKE_CURRENT_BINARY_DIR}/${ANTLR_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${QHEXEDIT_DIR} ${CMAKE_CURRENT_BINARY_DIR}/${QCUSTOMPLOT_DIR})

target_link_libraries(${PROJECT_NAME} antlr qhexedit ${QT_LIBRARIES} ${WIN32_STATIC_LINK} sqlite3 ${ADDITIONAL_LIBS})
target_link_libraries(${PROJECT_NAME} antlr qhexedit qcustomplot ${QT_LIBRARIES} ${WIN32_STATIC_LINK} sqlite3 ${ADDITIONAL_LIBS})

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
Expand Down
33 changes: 33 additions & 0 deletions libs/qcustomplot-source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
cmake_minimum_required(VERSION 2.8.9)

if(USE_QT5)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Qt5Widgets REQUIRED)
else()
find_package(Qt4 COMPONENTS QtCore QtGui REQUIRED)
include(${QT_USE_FILE})
add_definitions(${QT_DEFINITIONS})
endif()

set(QCUSTOMPLOT_SRC
qcustomplot.cpp
)

set(QCUSTOMPLOT_HDR
)

set(QCUSTOMPLOT_MOC_HDR
qcustomplot.h
)

if(NOT USE_QT5)
QT4_WRAP_CPP(QCUSTOMPLOT_MOC ${QCUSTOMPLOT_MOC_HDR})
endif()

add_library(qcustomplot ${QCUSTOMPLOT_SRC} ${QCUSTOMPLOT_HDR} ${QCUSTOMPLOT_MOC})

if(USE_QT5)
qt5_use_modules(qcustomplot Widgets PrintSupport)
endif()

2 changes: 1 addition & 1 deletion src/MainWindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1359,7 +1359,7 @@
<customwidget>
<class>QCustomPlot</class>
<extends>QWidget</extends>
<header>libs/qcustomplot-source/qcustomplot.h</header>
<header>qcustomplot.h</header>
<container>1</container>
</customwidget>
</customwidgets>
Expand Down

0 comments on commit 0ecff2c

Please sign in to comment.