forked from commonqt/commonqt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
68 lines (53 loc) · 1.88 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
cmake_minimum_required(VERSION 3.2.2)
if(NOT SMOKE_QT_VERSION)
project(commonqt LANGUAGES CXX)
set(COMMONQT commonqt)
elseif (${SMOKE_QT_VERSION} EQUAL 6)
project(commonqt6 LANGUAGES CXX)
set(COMMONQT commonqt6)
endif()
set(CMAKE_INCLUDE_CURRENT_DIR OFF)
set(CMAKE_AUTOMOC OFF)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT SMOKE_QT_VERSION)
set(SMOKE_QT_VERSION 5)
endif()
set(QT_VERSION Qt${SMOKE_QT_VERSION})
if (Qt5_DIR)
string(REPLACE "/lib/cmake/Qt5" "" Qt_ROOT_DIR ${Qt5_DIR})
elseif(Qt6_DIR)
string(REPLACE "/lib/cmake/Qt6" "" Qt_ROOT_DIR ${Qt6_DIR})
endif()
set(Qt5PrintSupport_DIR ${Qt_ROOT_DIR}/lib/cmake/Qt5PrintSupport)
find_package(${QT_VERSION} COMPONENTS Core REQUIRED)
find_package(${QT_VERSION}
COMPONENTS
Gui
Widgets
REQUIRED
)
find_package(${QT_VERSION}PrintSupport REQUIRED)
find_package(Smoke REQUIRED )
if (Qt6_FOUND)
set(QT_CORE_VERSION ${Qt6Core_VERSION})
else()
set(QT_CORE_VERSION ${Qt5Core_VERSION})
endif()
message(STATUS "Found ${QT_VERSION}: version ${QT_CORE_VERSION}")
message(STATUS "Found ${SMOKE_LIB}/include")
include_directories(${Qt_ROOT_DIR}/include/QtCore/${QT_CORE_VERSION}
${Qt_ROOT_DIR}/include/QtCore/${QT_CORE_VERSION}/QtCore
${SMOKE_LIB}/include)
link_directories(${SMOKE_LIB}/lib)
add_library(${COMMONQT} SHARED commonqt.cpp)
if (Qt6_FOUND)
target_link_libraries(${COMMONQT} smokeqt6core smokebase ${QT_VERSION}::Widgets ${QT_VERSION}::PrintSupport)
else()
target_link_libraries(${COMMONQT} smokeqtcore smokebase ${QT_VERSION}::Widgets ${QT_VERSION}::PrintSupport)
endif()
if(WIN32)
install( TARGETS ${COMMONQT} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin)
else()
install( TARGETS ${COMMONQT} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
endif()