Files
ResInsight/Fwk/VizFwk/TestApps/Qt/QtSnippetRunner/CMakeLists.txt
2018-11-30 09:47:53 +01:00

95 lines
2.6 KiB
CMake

cmake_minimum_required(VERSION 2.8.12)
project(QtSnippetRunner)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_BASE_CXX_FLAGS}")
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-long-long")
endif()
find_package(OpenGL)
find_package(Qt5 CONFIG COMPONENTS Core)
if (Qt5Core_FOUND)
message(STATUS "Found Qt5")
find_package(Qt5 CONFIG REQUIRED Core Gui OpenGL Widgets)
else()
find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED)
include(${QT_USE_FILE})
if (QT4_FOUND)
message(STATUS "Found Qt4")
endif(QT4_FOUND)
endif(Qt5Core_FOUND)
include_directories(${LibCore_SOURCE_DIR})
include_directories(${LibGeometry_SOURCE_DIR})
include_directories(${LibRender_SOURCE_DIR})
include_directories(${LibViewing_SOURCE_DIR})
include_directories(${LibGuiQt_SOURCE_DIR})
include_directories(${LibUtilities_SOURCE_DIR})
include_directories(${SnippetsBasis_SOURCE_DIR})
set(CEE_LIBS SnippetsBasis freetype LibFreeType LibUtilities LibGuiQt LibViewing LibRender LibGeometry LibIo LibCore opengl32)
include_directories(${SnippetsModules_SOURCE_DIR})
set(CEE_LIBS LibStructGrid ${CEE_LIBS})
set(CEE_SOURCE_FILES
QSRCommandLineArgs.cpp
QSRMain.cpp
QSRMainWindow.cpp
QSRPropertiesPanel.cpp
QSRRunPanel.cpp
QSRSnippetWidget.cpp
QSRStdInclude.cpp
QSRTranslateEvent.cpp
)
# Headers that need MOCing
set(MOC_HEADER_FILES
QSRMainWindow.h
QSRPropertiesPanel.h
QSRRunPanel.h
QSRSnippetWidget.h
)
# Run MOC on the headers
add_definitions(-DCVF_USING_CMAKE)
set(MOC_SOURCE_FILES)
if (Qt5Core_FOUND)
qt5_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} )
set(QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::OpenGL Qt5::Widgets)
else()
qt4_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} )
endif()
add_executable(${PROJECT_NAME} ${CEE_SOURCE_FILES} ${MOC_SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${CEE_LIBS} ${OPENGL_LIBRARIES} ${QT_LIBRARIES})
if (Qt5Core_FOUND)
foreach (qtlib ${QT_LIBRARIES})
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${qtlib}> $<TARGET_FILE_DIR:${PROJECT_NAME}>
)
endforeach(qtlib)
# Copy Qt Dlls
else()
# Copy Qt Dlls
if (MSVC)
set (QTLIBLIST QtCore QtGui QtOpenGl)
foreach (qtlib ${QTLIBLIST})
# Debug
execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}d4.dll ${CMAKE_BINARY_DIR}/Debug/${qtlib}d4.dll)
# Release
execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}4.dll ${CMAKE_BINARY_DIR}/Release/${qtlib}4.dll)
endforeach( qtlib )
endif(MSVC)
endif(Qt5Core_FOUND)