Skip to content

Commit a449d82

Browse files
authored
build(cmake): minor tweaks (yhirose#1274)
- Enable THREADS_PREFER_PTHREAD_FLAG to use -pthread where supported - Remove low-level compile features (closes yhirose#1272) - Remove unneeded DESTINATION options where possible
1 parent fee8e97 commit a449d82

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

CMakeLists.txt

+4-15
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ if (BUILD_SHARED_LIBS AND WIN32 AND HTTPLIB_COMPILE)
100100
endif()
101101

102102
# Threads needed for <thread> on some systems, and for <pthread.h> on Linux
103+
set(THREADS_PREFER_PTHREAD_FLAG true)
103104
find_package(Threads REQUIRED)
104105
# Since Cmake v3.11, Crypto & SSL became optional when not specified as COMPONENTS.
105106
if(HTTPLIB_REQUIRE_OPENSSL)
@@ -160,7 +161,7 @@ if(HTTPLIB_COMPILE)
160161
ERROR_VARIABLE _httplib_split_error
161162
)
162163
if(_httplib_split_error)
163-
message(FATAL_ERROR "Failed when trying to split Cpp-httplib with the Python script.\n${_httplib_split_error}")
164+
message(FATAL_ERROR "Failed when trying to split cpp-httplib with the Python script.\n${_httplib_split_error}")
164165
endif()
165166

166167
# split.py puts output in "out"
@@ -187,19 +188,9 @@ endif()
187188
# Only useful if building in-tree, versus using it from an installation.
188189
add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME})
189190

190-
# Might be missing some, but this list is somewhat comprehensive
191+
# Require C++11
191192
target_compile_features(${PROJECT_NAME} ${_INTERFACE_OR_PUBLIC}
192193
cxx_std_11
193-
cxx_nullptr
194-
cxx_lambdas
195-
cxx_override
196-
cxx_defaulted_functions
197-
cxx_attribute_deprecated
198-
cxx_auto_type
199-
cxx_decltype
200-
cxx_deleted_functions
201-
cxx_range_for
202-
cxx_sizeof_member
203194
)
204195

205196
target_include_directories(${PROJECT_NAME} ${_INTERFACE_OR_PUBLIC}
@@ -274,11 +265,9 @@ endif()
274265
# and linkage information (doesn't find deps though).
275266
install(TARGETS ${PROJECT_NAME}
276267
EXPORT httplibTargets
277-
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
278-
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
279268
)
280269

281-
install(FILES "${_httplib_build_includedir}/httplib.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
270+
install(FILES "${_httplib_build_includedir}/httplib.h" TYPE INCLUDE)
282271

283272
install(FILES
284273
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"

0 commit comments

Comments
 (0)