mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-07 01:06:45 +08:00
add options for cmake
This commit is contained in:
parent
647f7a2efb
commit
f07fc84cb8
@ -21,7 +21,7 @@ before_install:
|
|||||||
|
|
||||||
script:
|
script:
|
||||||
- mkdir -p ./build && cd ./build
|
- mkdir -p ./build && cd ./build
|
||||||
- cmake -DCMAKE_BUILD_TYPE=Release ..
|
- cmake -DCMAKE_BUILD_TYPE=Release -DLIBIPC_BUILD_TESTS=ON ..
|
||||||
- make -j`nproc`
|
- make -j`nproc`
|
||||||
- export LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH && ./bin/test-ipc
|
- export LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH && ./bin/test-ipc
|
||||||
|
|
||||||
|
|||||||
18
CMakeLists.txt
Normal file → Executable file
18
CMakeLists.txt
Normal file → Executable file
@ -1,6 +1,9 @@
|
|||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
project(cpp-ipc)
|
project(cpp-ipc)
|
||||||
|
|
||||||
|
option(LIBIPC_BUILD_TESTS "Build all of libipc's own tests." OFF)
|
||||||
|
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)
|
||||||
@ -11,15 +14,20 @@ include_directories(${CMAKE_SOURCE_DIR}/include)
|
|||||||
|
|
||||||
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
|
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
|
||||||
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
|
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
|
||||||
|
set(LIBIPC_PROJECT_DIR ${PROJECT_SOURCE_DIR})
|
||||||
|
|
||||||
add_subdirectory(src)
|
add_subdirectory(src)
|
||||||
|
|
||||||
set(GOOGLETEST_VERSION 1.10.0)
|
if (LIBIPC_BUILD_TESTS)
|
||||||
add_subdirectory(3rdparty/gtest)
|
set(GOOGLETEST_VERSION 1.10.0)
|
||||||
add_subdirectory(test)
|
add_subdirectory(3rdparty/gtest)
|
||||||
|
add_subdirectory(test)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_subdirectory(demo/chat)
|
if (LIBIPC_BUILD_DEMOS)
|
||||||
add_subdirectory(demo/msg_que)
|
add_subdirectory(demo/chat)
|
||||||
|
add_subdirectory(demo/msg_que)
|
||||||
|
endif()
|
||||||
|
|
||||||
install(
|
install(
|
||||||
DIRECTORY "include/"
|
DIRECTORY "include/"
|
||||||
|
|||||||
2
demo/msg_que/CMakeLists.txt
Normal file → Executable file
2
demo/msg_que/CMakeLists.txt
Normal file → Executable file
@ -1,7 +1,7 @@
|
|||||||
project(msg_que)
|
project(msg_que)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${CMAKE_SOURCE_DIR}/3rdparty)
|
${LIBIPC_PROJECT_DIR}/3rdparty)
|
||||||
|
|
||||||
file(GLOB SRC_FILES ./*.cpp)
|
file(GLOB SRC_FILES ./*.cpp)
|
||||||
file(GLOB HEAD_FILES ./*.h)
|
file(GLOB HEAD_FILES ./*.h)
|
||||||
|
|||||||
@ -7,24 +7,24 @@ if(NOT MSVC)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${CMAKE_SOURCE_DIR}/include
|
${LIBIPC_PROJECT_DIR}/include
|
||||||
${CMAKE_SOURCE_DIR}/src)
|
${LIBIPC_PROJECT_DIR}/src)
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
file(GLOB SRC_FILES ${CMAKE_SOURCE_DIR}/src/libipc/platform/*_linux.cpp)
|
file(GLOB SRC_FILES ${LIBIPC_PROJECT_DIR}/src/libipc/platform/*_linux.cpp)
|
||||||
else()
|
else()
|
||||||
file(GLOB SRC_FILES ${CMAKE_SOURCE_DIR}/src/libipc/platform/*_win.cpp)
|
file(GLOB SRC_FILES ${LIBIPC_PROJECT_DIR}/src/libipc/platform/*_win.cpp)
|
||||||
endif()
|
endif()
|
||||||
aux_source_directory(${CMAKE_SOURCE_DIR}/src SRC_FILES)
|
aux_source_directory(${LIBIPC_PROJECT_DIR}/src SRC_FILES)
|
||||||
|
|
||||||
file(GLOB HEAD_FILES
|
file(GLOB HEAD_FILES
|
||||||
${CMAKE_SOURCE_DIR}/include/libipc/*.h
|
${LIBIPC_PROJECT_DIR}/include/libipc/*.h
|
||||||
${CMAKE_SOURCE_DIR}/src/libipc/*.h
|
${LIBIPC_PROJECT_DIR}/src/libipc/*.h
|
||||||
${CMAKE_SOURCE_DIR}/src/libipc/*.inc
|
${LIBIPC_PROJECT_DIR}/src/libipc/*.inc
|
||||||
${CMAKE_SOURCE_DIR}/src/libipc/circ/*.h
|
${LIBIPC_PROJECT_DIR}/src/libipc/circ/*.h
|
||||||
${CMAKE_SOURCE_DIR}/src/libipc/memory/*.h
|
${LIBIPC_PROJECT_DIR}/src/libipc/memory/*.h
|
||||||
${CMAKE_SOURCE_DIR}/src/libipc/platform/*.h
|
${LIBIPC_PROJECT_DIR}/src/libipc/platform/*.h
|
||||||
${CMAKE_SOURCE_DIR}/src/libipc/utility/*.h)
|
${LIBIPC_PROJECT_DIR}/src/libipc/utility/*.h)
|
||||||
|
|
||||||
add_library(${PROJECT_NAME} SHARED ${SRC_FILES} ${HEAD_FILES})
|
add_library(${PROJECT_NAME} SHARED ${SRC_FILES} ${HEAD_FILES})
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
|
|||||||
@ -9,17 +9,17 @@ if(NOT MSVC)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${CMAKE_SOURCE_DIR}/include
|
${LIBIPC_PROJECT_DIR}/include
|
||||||
${CMAKE_SOURCE_DIR}/src
|
${LIBIPC_PROJECT_DIR}/src
|
||||||
${CMAKE_SOURCE_DIR}/test
|
${LIBIPC_PROJECT_DIR}/test
|
||||||
${CMAKE_SOURCE_DIR}/3rdparty
|
${LIBIPC_PROJECT_DIR}/3rdparty
|
||||||
${CMAKE_SOURCE_DIR}/3rdparty/gtest/include)
|
${LIBIPC_PROJECT_DIR}/3rdparty/gtest/include)
|
||||||
|
|
||||||
file(GLOB SRC_FILES ${CMAKE_SOURCE_DIR}/test/*.cpp)
|
file(GLOB SRC_FILES ${LIBIPC_PROJECT_DIR}/test/*.cpp)
|
||||||
file(GLOB HEAD_FILES ${CMAKE_SOURCE_DIR}/test/*.h)
|
file(GLOB HEAD_FILES ${LIBIPC_PROJECT_DIR}/test/*.h)
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} ${SRC_FILES} ${HEAD_FILES})
|
add_executable(${PROJECT_NAME} ${SRC_FILES} ${HEAD_FILES})
|
||||||
|
|
||||||
link_directories(${CMAKE_SOURCE_DIR}/3rdparty/gperftools)
|
link_directories(${LIBIPC_PROJECT_DIR}/3rdparty/gperftools)
|
||||||
target_link_libraries(${PROJECT_NAME} gtest gtest_main ipc)
|
target_link_libraries(${PROJECT_NAME} gtest gtest_main ipc)
|
||||||
#target_link_libraries(${PROJECT_NAME} tcmalloc_minimal)
|
#target_link_libraries(${PROJECT_NAME} tcmalloc_minimal)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user