-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
68 lines (51 loc) · 2.34 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.5)
project(qpcx)
if (MSVC)
if(NOT QT_QMAKE_EXECUTABLE)
find_program(QT_QMAKE_EXECUTABLE NAMES "qmake" "qmake-qt5" "qmake.exe")
endif()
if(NOT QT_QMAKE_EXECUTABLE)
message(FATAL_ERROR "you have to set the path to the Qt5 qmake executable in CMakeUserPaths.cmake")
endif()
message(STATUS "QMake found: ${QT_QMAKE_EXECUTABLE}")
get_filename_component(QT_QMAKE_PATH ${QT_QMAKE_EXECUTABLE} PATH)
set(QT_ROOT ${QT_QMAKE_PATH}/)
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${QT_QMAKE_PATH}/../lib/cmake/Qt5)
endif()
find_package(Qt5 COMPONENTS Core Gui REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
file(GLOB LIBQPCX_SOURCES "*.cpp")
file(GLOB LIBQPCX_HEADERS "*.h")
SET(CMAKE_DEBUG_POSTFIX "d")
add_library(${PROJECT_NAME} MODULE ${LIBQPCX_SOURCES} ${LIBQPCX_HEADERS})
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui)
set_target_properties(${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_CURRENT_BINARY_DIR}/libs)
set_target_properties(${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_CURRENT_BINARY_DIR}/libs)
set_target_properties(${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_REALLYRELEASE ${CMAKE_CURRENT_BINARY_DIR}/libs)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/imageformats")
# install to qt plugins dir
execute_process(
COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_PLUGINS
OUTPUT_VARIABLE QT_PLUGINS_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
if (QT_PLUGINS_DIR)
# status
message(STATUS "")
message(STATUS "-----------------------------------------------------------------------------")
message(STATUS " ${PROJECT_NAME} configured")
message(STATUS " https://github.com/roniemartinez/libqpcx")
message(STATUS " it will be installed to ${QT_PLUGINS_DIR}/imageformats")
message(STATUS "-----------------------------------------------------------------------------")
else ()
message(FATAL_ERROR "Qt5 plugin directory cannot be detected.")
endif ()
# Prefix with DESTDIR if available to allow packaging
if (ENV{DESTDIR} AND NOT ENV{DESTDIR} STREQUAL "")
set(plugins_dir "$ENV{DESTDIR}${QT_PLUGINS_DIR}")
else ()
set(plugins_dir "${QT_PLUGINS_DIR}")
endif ()
install(
TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION "${plugins_dir}/imageformats")