Skip to content

Commit 7cca519

Browse files
committed
Update build system
1 parent 6818c23 commit 7cca519

File tree

2 files changed

+41
-19
lines changed

2 files changed

+41
-19
lines changed

CMakeLists.txt

+32-5
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,31 @@ set(CMAKE_PREFIX_PATH
6969
"${CMAKE_PREFIX_PATH}"
7070
)
7171

72+
73+
7274
add_definitions(-DQT_NO_KEYWORDS)
73-
find_package(Qt5 REQUIRED Core Network)
74-
set(Qt5_INCLUDES ${Qt5_INCLUDES} ${Qt5Core_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS})
75-
set(Qt5_LIBRARIES ${Qt5_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5Network_LIBRARIES} )
75+
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0)
76+
if (NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Windows"))
77+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -DQT_DEPRECATED_WARNINGS")
78+
else()
79+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DQT_COMPILING_QSTRING_COMPAT_CPP -D_SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS")
80+
endif()
7681

77-
include_directories(${Qt5_INCLUDES})
78-
set(QT_LIBRARIES "${Qt5_LIBRARIES}")
82+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
83+
set(CMAKE_AUTOMOC ON)
84+
find_package(Qt5 REQUIRED COMPONENTS Core Network)
85+
set(Qt5_LIBRARIES Qt5::Core Qt5::Network )
86+
message("Found Qt5 ${Qt5Core_VERSION}")
87+
88+
message("\n\n\n{Qt5_LIBRARIES}=${Qt5_LIBRARIES} ")
89+
90+
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
91+
get_target_property(QtCore_location Qt5::Core LOCATION)
92+
get_target_property(QtNetwork_location Qt5::Network LOCATION)
93+
install(FILES ${QtCore_location}
94+
${QtNetwork_location}
95+
DESTINATION ${LIB_INSTALL_DIR})
96+
endif ()
7997

8098
add_subdirectory(src)
8199
#add_subdirectory(test)
@@ -95,6 +113,15 @@ add_subdirectory(src)
95113
#endif(DOXYGEN_FOUND)
96114

97115
########### packaging ###############
116+
# Specify additional runtime libraries that may not be detected. After
117+
# inclusion any detected libraries will be appended to this.
118+
set(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS
119+
${QtCore_location}
120+
${QtNetwork_location}
121+
)
122+
123+
set(CMAKE_INSTALL_DEBUG_LIBRARIES TRUE)
124+
set(MAKE_INSTALL_UCRT_LIBRARIES TRUE)
98125
INCLUDE(InstallRequiredSystemLibraries)
99126

100127
if(NOT DEFINED VERSION_RELEASE)

src/CMakeLists.txt

+9-14
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,21 @@
1-
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/http-parser)
1+
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/http-parser)
22

33
add_definitions( -DQHTTPSERVER_EXPORT )
44

55
########### next target ###############
66

7-
set (qhttpserver_MOC_HEADERS
8-
qhttpconnection.h
9-
qhttprequest.h
10-
qhttpresponse.h
11-
qhttpserver.h
12-
)
13-
14-
qt5_wrap_cpp (qhttpserver_MOC_OUTFILES ${qhttpserver_MOC_HEADERS})
15-
167
SET(qhttpserver_LIB_SRCS
17-
qhttpconnection.cpp qhttprequest.cpp qhttpresponse.cpp qhttpserver.cpp
18-
../http-parser/http_parser.c ../http-parser/url_parser.c
8+
qhttpconnection.cpp
9+
qhttprequest.cpp
10+
qhttpresponse.cpp
11+
qhttpserver.cpp
12+
../http-parser/http_parser.c
13+
../http-parser/url_parser.c
1914
)
2015

21-
add_library(qhttpserver SHARED ${qhttpserver_LIB_SRCS} ${qhttpserver_MOC_OUTFILES})
16+
add_library(qhttpserver SHARED ${qhttpserver_LIB_SRCS})
2217

23-
target_link_libraries(qhttpserver ${QT_LIBRARIES})
18+
target_link_libraries(qhttpserver ${Qt5_LIBRARIES})
2419

2520
install(TARGETS qhttpserver DESTINATION lib)
2621

0 commit comments

Comments
 (0)