mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
option(LIBIPC_BUILD_SHARED_LIBS 'Build shared libraries (DLLs).' OFF)
This commit is contained in:
parent
57e5298006
commit
cca4664e84
@ -7,7 +7,7 @@ option(LIBIPC_BUILD_DEMOS "Build all of libipc's own demos." OFF)
|
|||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/include)
|
include_directories(${CMAKE_SOURCE_DIR}/include)
|
||||||
@ -19,14 +19,14 @@ set(LIBIPC_PROJECT_DIR ${PROJECT_SOURCE_DIR})
|
|||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
if (LIBIPC_BUILD_TESTS)
|
if (LIBIPC_BUILD_TESTS)
|
||||||
set(GOOGLETEST_VERSION 1.10.0)
|
set(GOOGLETEST_VERSION 1.10.0)
|
||||||
add_subdirectory(3rdparty/gtest)
|
add_subdirectory(3rdparty/gtest)
|
||||||
add_subdirectory(test)
|
add_subdirectory(test)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (LIBIPC_BUILD_DEMOS)
|
if (LIBIPC_BUILD_DEMOS)
|
||||||
add_subdirectory(demo/chat)
|
add_subdirectory(demo/chat)
|
||||||
add_subdirectory(demo/msg_que)
|
add_subdirectory(demo/msg_que)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(
|
install(
|
||||||
|
|||||||
@ -44,9 +44,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef IPC_EXPORT
|
#ifndef IPC_EXPORT
|
||||||
#if defined(__IPC_LIBRARY__)
|
#if defined(LIBIPC_LIBRARY_SHARED_BUILDING__)
|
||||||
# define IPC_EXPORT IPC_DECL_EXPORT
|
# define IPC_EXPORT IPC_DECL_EXPORT
|
||||||
#else
|
#elif defined(LIBIPC_LIBRARY_SHARED_USING__)
|
||||||
# define IPC_EXPORT IPC_DECL_IMPORT
|
# define IPC_EXPORT IPC_DECL_IMPORT
|
||||||
|
#else
|
||||||
|
# define IPC_EXPORT
|
||||||
#endif
|
#endif
|
||||||
#endif /*IPC_EXPORT*/
|
#endif /*IPC_EXPORT*/
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
project(ipc)
|
project(ipc)
|
||||||
|
|
||||||
add_compile_options(-D__IPC_LIBRARY__)
|
option(LIBIPC_BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF)
|
||||||
|
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
add_compile_options(-fPIC)
|
add_compile_options(-fPIC)
|
||||||
@ -26,11 +26,21 @@ file(GLOB HEAD_FILES
|
|||||||
${LIBIPC_PROJECT_DIR}/src/libipc/platform/*.h
|
${LIBIPC_PROJECT_DIR}/src/libipc/platform/*.h
|
||||||
${LIBIPC_PROJECT_DIR}/src/libipc/utility/*.h)
|
${LIBIPC_PROJECT_DIR}/src/libipc/utility/*.h)
|
||||||
|
|
||||||
add_library(${PROJECT_NAME} SHARED ${SRC_FILES} ${HEAD_FILES})
|
if (LIBIPC_BUILD_SHARED_LIBS)
|
||||||
|
add_library(${PROJECT_NAME} SHARED ${SRC_FILES} ${HEAD_FILES})
|
||||||
|
target_compile_definitions(${PROJECT_NAME}
|
||||||
|
INTERFACE
|
||||||
|
LIBIPC_LIBRARY_SHARED_USING__
|
||||||
|
PRIVATE
|
||||||
|
LIBIPC_LIBRARY_SHARED_BUILDING__)
|
||||||
|
else()
|
||||||
|
add_library(${PROJECT_NAME} STATIC ${SRC_FILES} ${HEAD_FILES})
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC
|
target_link_libraries(${PROJECT_NAME} PUBLIC
|
||||||
pthread
|
pthread
|
||||||
$<$<NOT:$<STREQUAL:${CMAKE_SYSTEM_NAME},Windows>>:rt>)
|
$<$<NOT:$<STREQUAL:${CMAKE_SYSTEM_NAME},Windows>>:rt>)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
install(
|
install(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user