File tree Expand file tree Collapse file tree 3 files changed +24
-12
lines changed Expand file tree Collapse file tree 3 files changed +24
-12
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ option(LIBIPC_BUILD_DEMOS "Build all of libipc's own demos." OFF)
77set (CMAKE_CXX_STANDARD 17)
88set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG" )
99if (NOT MSVC )
10- set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2" )
10+ set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2" )
1111endif ()
1212
1313include_directories (${CMAKE_SOURCE_DIR} /include )
@@ -19,14 +19,14 @@ set(LIBIPC_PROJECT_DIR ${PROJECT_SOURCE_DIR})
1919add_subdirectory (src)
2020
2121if (LIBIPC_BUILD_TESTS)
22- set (GOOGLETEST_VERSION 1.10.0)
23- add_subdirectory (3rdparty/gtest)
24- add_subdirectory (test )
22+ set (GOOGLETEST_VERSION 1.10.0)
23+ add_subdirectory (3rdparty/gtest)
24+ add_subdirectory (test )
2525endif ()
2626
2727if (LIBIPC_BUILD_DEMOS)
28- add_subdirectory (demo/chat)
29- add_subdirectory (demo/msg_que)
28+ add_subdirectory (demo/chat)
29+ add_subdirectory (demo/msg_que)
3030endif ()
3131
3232install (
Original file line number Diff line number Diff line change 4444*/
4545
4646#ifndef IPC_EXPORT
47- #if defined(__IPC_LIBRARY__ )
47+ #if defined(LIBIPC_LIBRARY_SHARED_BUILDING__ )
4848# define IPC_EXPORT IPC_DECL_EXPORT
49- #else
49+ #elif defined( LIBIPC_LIBRARY_SHARED_USING__ )
5050# define IPC_EXPORT IPC_DECL_IMPORT
51+ #else
52+ # define IPC_EXPORT
5153#endif
5254#endif /*IPC_EXPORT*/
Original file line number Diff line number Diff line change 11project (ipc)
22
3- add_compile_options (-D__IPC_LIBRARY__ )
3+ option (LIBIPC_BUILD_SHARED_LIBS "Build shared libraries (DLLs)." OFF )
44
55if (NOT MSVC )
66 add_compile_options (-fPIC)
@@ -26,11 +26,21 @@ file(GLOB HEAD_FILES
2626 ${LIBIPC_PROJECT_DIR} /src/libipc/platform/*.h
2727 ${LIBIPC_PROJECT_DIR} /src/libipc/utility/*.h)
2828
29- add_library (${PROJECT_NAME} SHARED ${SRC_FILES} ${HEAD_FILES} )
29+ if (LIBIPC_BUILD_SHARED_LIBS)
30+ add_library (${PROJECT_NAME} SHARED ${SRC_FILES} ${HEAD_FILES} )
31+ target_compile_definitions (${PROJECT_NAME}
32+ INTERFACE
33+ LIBIPC_LIBRARY_SHARED_USING__
34+ PRIVATE
35+ LIBIPC_LIBRARY_SHARED_BUILDING__)
36+ else ()
37+ add_library (${PROJECT_NAME} STATIC ${SRC_FILES} ${HEAD_FILES} )
38+ endif ()
39+
3040if (NOT MSVC )
3141 target_link_libraries (${PROJECT_NAME} PUBLIC
32- pthread
33- $<$<NOT :$<STREQUAL :${CMAKE_SYSTEM_NAME} ,Windows>>:rt>)
42+ pthread
43+ $<$<NOT :$<STREQUAL :${CMAKE_SYSTEM_NAME} ,Windows>>:rt>)
3444endif ()
3545
3646install (
You can’t perform that action at this time.
0 commit comments