-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
143 lines (112 loc) · 4.09 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
cmake_minimum_required(VERSION 3.3)
#
project(qt5menugen
VERSION 2.1.1
DESCRIPTION "Generate Mac OSX, Windows and Linux -specific toolbars and menus via a json file"
LANGUAGES CXX)
include(GNUInstallDirs) # REQUIRED TO INSTALL PKGCONFIG TO PROPER DIR, and after LANGUAGES is defined
# Immediately set the version.h header
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/version.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/version.h)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5 REQUIRED
Core
Widgets
Gui
Test
)
set(PACKAGE_HEADERS
qt5menugen.h
)
list(APPEND QT5MENUGEN_HEADERS
src/qt5menugen.h
src/qt5menugen_global.h
src/version.h
)
list(APPEND QT5MENUGEN_SOURCES
src/qt5menugen.cpp
)
add_library(${PROJECT_NAME}
SHARED
${QT5MENUGEN_HEADERS}
${QT5MENUGEN_SOURCES}
)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets)
target_include_directories(${PROJECT_NAME} PUBLIC src/)
list(APPEND TEST_SOURCES
tests/test_runner.cpp
tests/test_qwidget_menu.cpp
)
list(APPEND TEST_HEADERS
tests/test_qwidget_menu.h
)
list(APPEND TEST_UIS
)
# common/common.qrc contains the collection of spec file definitions
list(APPEND TEST_RES
)
# We need to include spec files from other qrc files, so add them relative to here:
list(APPEND TEST_OTHER
)
add_executable("${PROJECT_NAME}-tests"
${TEST_HEADERS}
${TEST_SOURCES}
${TEST_UIS}
${TEST_RES}
)
if(APPLE)
find_package(Qt5 REQUIRED MacExtras)
target_link_libraries(${PROJECT_NAME} Qt5::MacExtras)
elseif(MSVC)
find_package(Qt5 HINTS "$ENV{QT5_DIR}" COMPONENTS Core Quick REQUIRED)
set(CMAKE_PREFIX_PATH "C:\\Qt\\5.3.1\\5.3\\msvc2013_opengl")
set(Qt5_DIR "C:/Qt/Qt5.3.2/5.3/msvc2013_64_opengl/")
find_package(Qt5 COMPONENTS WinExtras REQUIRED)
target_link_libraries(${PROJECT_NAME} Qt5::WinExtras)
endif()
# Remove this line when deploying
include_directories(BEFORE /usr/local/Qt-5.3.2/lib)
target_include_directories(${PROJECT_NAME} BEFORE PRIVATE .. )
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Test)
target_link_libraries("${PROJECT_NAME}-tests" Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Test)
if(APPLE)
find_package(Qt5 REQUIRED MacExtras)
target_link_libraries(${PROJECT_NAME} Qt5::MacExtras)
elseif(MSVC)
find_package(Qt5 HINTS "$ENV{QT5_DIR}" COMPONENTS Core Quick REQUIRED)
set(CMAKE_PREFIX_PATH "C:\\Qt\\5.3.1\\5.3\\msvc2013_opengl")
set(Qt5_DIR "C:/Qt/Qt5.3.2/5.3/msvc2013_64_opengl/")
find_package(Qt5 COMPONENTS WinExtras REQUIRED)
target_link_libraries(${PROJECT_NAME} Qt5::WinExtras)
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${PROJECT_VERSION}
SOVERSION 2
)
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${QT5MENUGEN_HEADERS}")
configure_file(src/qt5menugen.pc.in src/qt5menugen.pc @ONLY)
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
include(CMakePackageConfigHelpers)
# Create directory
file(MAKE_DIRECTORY ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}
CACHE PATH "Location of header files" )
set(SYSCONFIG_INSTALL_DIR ${CMAKE_INSTALL_SYSCONFDIR}/${PROJECT_NAME}
CACHE PATH "Location of configuration files" )
#...
include(CMakePackageConfigHelpers)
configure_package_config_file(${PROJECT_NAME}-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
PATH_VARS INCLUDE_INSTALL_DIR SYSCONFIG_INSTALL_DIR)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
VERSION ${VERSION}
COMPATIBILITY SameMajorVersion )
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} )
install(FILES ${CMAKE_BINARY_DIR}/src/qt5menugen.pc DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)