mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Fix a number of CMake problems: clang detection, shared library support, etc.
This commit is contained in:
@@ -39,11 +39,12 @@ set (WEBSOCKETPP_BOOST_LIBS "")
|
||||
# VC9 and C++11 reasoning
|
||||
if (ENABLE_CPP11 AND MSVC AND MSVC90)
|
||||
message("* Detected Visual Studio 9 2008, disabling C++11 support.")
|
||||
set (ENABLE_CPP11 FALSE)
|
||||
set (ENABLE_CPP11 FALSE)
|
||||
endif ()
|
||||
|
||||
# Detect clang. Not officially reported by cmake.
|
||||
if ("${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" MATCHES ".*clang")
|
||||
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-v" ERROR_VARIABLE CXX_VER_STDERR)
|
||||
if ("${CXX_VER_STDERR}" MATCHES ".*clang.*")
|
||||
set (CMAKE_COMPILER_IS_CLANGXX 1)
|
||||
endif ()
|
||||
|
||||
@@ -67,7 +68,7 @@ endif ()
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
set (WEBSOCKETPP_PLATFORM_LIBS pthread rt)
|
||||
set (WEBSOCKETPP_PLATFORM_TSL_LIBS ssl crypto)
|
||||
set (WEBSOCKETPP_BOOST_LIBS system thread)
|
||||
set (WEBSOCKETPP_BOOST_LIBS system thread regex)
|
||||
set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++0x")
|
||||
if (NOT APPLE)
|
||||
add_definitions (-DNDEBUG -Wall -Wcast-align) # todo: should we use CMAKE_C_FLAGS for these?
|
||||
@@ -84,8 +85,13 @@ endif ()
|
||||
|
||||
# clang
|
||||
if (CMAKE_COMPILER_IS_CLANGXX)
|
||||
set (WEBSOCKETPP_PLATFORM_LIBS pthread rt)
|
||||
if (NOT APPLE)
|
||||
set (WEBSOCKETPP_PLATFORM_LIBS pthread rt)
|
||||
else()
|
||||
set (WEBSOCKETPP_PLATFORM_LIBS pthread)
|
||||
endif()
|
||||
set (WEBSOCKETPP_PLATFORM_TSL_LIBS ssl crypto)
|
||||
set (WEBSOCKETPP_BOOST_LIBS system thread regex)
|
||||
set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++0x -stdlib=libc++") # todo: is libc++ really needed here?
|
||||
if (NOT APPLE)
|
||||
add_definitions (-DNDEBUG -Wall -Wno-padded) # todo: should we use CMAKE_C_FLAGS for these?
|
||||
@@ -94,7 +100,7 @@ endif ()
|
||||
|
||||
# OSX, can override above.
|
||||
if (APPLE)
|
||||
add_definitions (-DNDEBUG -Wall -O0)
|
||||
add_definitions (-DNDEBUG -Wall)
|
||||
endif ()
|
||||
|
||||
|
||||
@@ -114,6 +120,9 @@ if (MSVC)
|
||||
set (CMAKE_INSTALL_PREFIX ${WEBSOCKETPP_PREFIX})
|
||||
endif ()
|
||||
|
||||
if (BUILD_EXAMPLES)
|
||||
list (APPEND WEBSOCKETPP_BOOST_LIBS random)
|
||||
endif()
|
||||
|
||||
############ Dependencies
|
||||
|
||||
|
||||
@@ -31,14 +31,14 @@ endmacro ()
|
||||
|
||||
# Adds the given folder_name into the source files of the current project.
|
||||
# Use this macro when your module contains .cpp and .h files in several subdirectories.
|
||||
# Your sources variable needs to be SOURCE_FILES and headers variable HEADER_FILES.
|
||||
# Your sources variable needs to be WSPP_SOURCE_FILES and headers variable WSPP_HEADER_FILES.
|
||||
macro(add_source_folder folder_name)
|
||||
file(GLOB H_FILES_IN_FOLDER_${folder_name} ${folder_name}/*.hpp ${folder_name}/*.h)
|
||||
file(GLOB CPP_FILES_IN_FOLDER_${folder_name} ${folder_name}/*.cpp ${folder_name}/*.c)
|
||||
source_group("Header Files\\${folder_name}" FILES ${H_FILES_IN_FOLDER_${folder_name}})
|
||||
source_group("Source Files\\${folder_name}" FILES ${CPP_FILES_IN_FOLDER_${folder_name}})
|
||||
set(HEADER_FILES ${HEADER_FILES} ${H_FILES_IN_FOLDER_${folder_name}})
|
||||
set(SOURCE_FILES ${SOURCE_FILES} ${CPP_FILES_IN_FOLDER_${folder_name}})
|
||||
set(WSPP_HEADER_FILES ${WSPP_HEADER_FILES} ${H_FILES_IN_FOLDER_${folder_name}})
|
||||
set(WSPP_SOURCE_FILES ${WSPP_SOURCE_FILES} ${CPP_FILES_IN_FOLDER_${folder_name}})
|
||||
endmacro()
|
||||
|
||||
# Initialize target.
|
||||
@@ -56,7 +56,7 @@ macro (build_library TARGET_NAME LIB_TYPE)
|
||||
set (TARGET_LIB_TYPE ${LIB_TYPE})
|
||||
message (STATUS "-- Build Type:")
|
||||
message (STATUS " " ${TARGET_LIB_TYPE} " library")
|
||||
|
||||
|
||||
add_library (${TARGET_NAME} ${TARGET_LIB_TYPE} ${ARGN})
|
||||
|
||||
target_link_libraries (${TARGET_NAME} ${WEBSOCKETPP_PLATFORM_LIBS})
|
||||
@@ -69,12 +69,10 @@ macro (build_library TARGET_NAME LIB_TYPE)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (${TARGET_LIB_TYPE} STREQUAL "STATIC")
|
||||
message (STATUS "-- Build Destination:")
|
||||
message (STATUS " " ${WEBSOCKETPP_LIB})
|
||||
set_target_properties (${TARGET_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${WEBSOCKETPP_LIB})
|
||||
endif ()
|
||||
message (STATUS "-- Build Destination:")
|
||||
message (STATUS " " ${WEBSOCKETPP_LIB})
|
||||
|
||||
set_target_properties (${TARGET_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${WEBSOCKETPP_LIB})
|
||||
set_target_properties (${TARGET_NAME} PROPERTIES DEBUG_POSTFIX d)
|
||||
endmacro ()
|
||||
|
||||
@@ -127,4 +125,4 @@ endmacro ()
|
||||
|
||||
macro (link_boost)
|
||||
target_link_libraries (${TARGET_NAME} ${Boost_LIBRARIES})
|
||||
endmacro ()
|
||||
endmacro ()
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
init_target (libwebsocketpp)
|
||||
|
||||
# Sources from root dir
|
||||
file (GLOB SOURCE_FILES *.cpp)
|
||||
file (GLOB HEADER_FILES *.hpp)
|
||||
file (GLOB WSPP_SOURCE_FILES *.cpp)
|
||||
file (GLOB WSPP_HEADER_FILES *.hpp)
|
||||
|
||||
# Sources from subdirectories.
|
||||
list_subdirectories (SUBDIRS ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
@@ -14,6 +14,11 @@ foreach (SUBDIR ${SUBDIRS})
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
build_library (${TARGET_NAME} STATIC ${SOURCE_FILES} ${HEADER_FILES})
|
||||
string(TOLOWER "${WEBSOCKETPP_LIB_BUILD_TYPE}" LOWER_WEBSOCKETPP_BUILD_TYPE)
|
||||
if ("${LOWER_WEBSOCKETPP_BUILD_TYPE}" STREQUAL "shared" )
|
||||
build_library (${TARGET_NAME} SHARED ${WSPP_SOURCE_FILES} ${WSPP_HEADER_FILES})
|
||||
else()
|
||||
build_library (${TARGET_NAME} STATIC ${WSPP_SOURCE_FILES} ${WSPP_HEADER_FILES})
|
||||
endif()
|
||||
|
||||
final_target ()
|
||||
final_target ()
|
||||
|
||||
@@ -306,7 +306,6 @@ public:
|
||||
connection_ptr get_con_from_hdl(connection_hdl hdl, lib::error_code & ec) {
|
||||
scoped_lock_type lock(m_mutex);
|
||||
connection_ptr con = lib::static_pointer_cast<connection_type>(
|
||||
#endif
|
||||
hdl.lock());
|
||||
if (!con) {
|
||||
ec = error::make_error_code(error::bad_connection);
|
||||
|
||||
Reference in New Issue
Block a user