mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
add options for cmake
This commit is contained in:
parent
647f7a2efb
commit
f07fc84cb8
@ -21,7 +21,7 @@ before_install:
|
||||
|
||||
script:
|
||||
- mkdir -p ./build && cd ./build
|
||||
- cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
- cmake -DCMAKE_BUILD_TYPE=Release -DLIBIPC_BUILD_TESTS=ON ..
|
||||
- make -j`nproc`
|
||||
- export LD_LIBRARY_PATH=./lib:$LD_LIBRARY_PATH && ./bin/test-ipc
|
||||
|
||||
|
||||
20
CMakeLists.txt
Normal file → Executable file
20
CMakeLists.txt
Normal file → Executable file
@ -1,25 +1,33 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
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_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
|
||||
if(NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
|
||||
endif()
|
||||
|
||||
include_directories(${CMAKE_SOURCE_DIR}/include)
|
||||
|
||||
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
|
||||
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
|
||||
set(LIBIPC_PROJECT_DIR ${PROJECT_SOURCE_DIR})
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
set(GOOGLETEST_VERSION 1.10.0)
|
||||
add_subdirectory(3rdparty/gtest)
|
||||
add_subdirectory(test)
|
||||
if (LIBIPC_BUILD_TESTS)
|
||||
set(GOOGLETEST_VERSION 1.10.0)
|
||||
add_subdirectory(3rdparty/gtest)
|
||||
add_subdirectory(test)
|
||||
endif()
|
||||
|
||||
add_subdirectory(demo/chat)
|
||||
add_subdirectory(demo/msg_que)
|
||||
if (LIBIPC_BUILD_DEMOS)
|
||||
add_subdirectory(demo/chat)
|
||||
add_subdirectory(demo/msg_que)
|
||||
endif()
|
||||
|
||||
install(
|
||||
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)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/3rdparty)
|
||||
${LIBIPC_PROJECT_DIR}/3rdparty)
|
||||
|
||||
file(GLOB SRC_FILES ./*.cpp)
|
||||
file(GLOB HEAD_FILES ./*.h)
|
||||
|
||||
@ -7,24 +7,24 @@ if(NOT MSVC)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/src)
|
||||
${LIBIPC_PROJECT_DIR}/include
|
||||
${LIBIPC_PROJECT_DIR}/src)
|
||||
|
||||
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()
|
||||
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()
|
||||
aux_source_directory(${CMAKE_SOURCE_DIR}/src SRC_FILES)
|
||||
aux_source_directory(${LIBIPC_PROJECT_DIR}/src SRC_FILES)
|
||||
|
||||
file(GLOB HEAD_FILES
|
||||
${CMAKE_SOURCE_DIR}/include/libipc/*.h
|
||||
${CMAKE_SOURCE_DIR}/src/libipc/*.h
|
||||
${CMAKE_SOURCE_DIR}/src/libipc/*.inc
|
||||
${CMAKE_SOURCE_DIR}/src/libipc/circ/*.h
|
||||
${CMAKE_SOURCE_DIR}/src/libipc/memory/*.h
|
||||
${CMAKE_SOURCE_DIR}/src/libipc/platform/*.h
|
||||
${CMAKE_SOURCE_DIR}/src/libipc/utility/*.h)
|
||||
${LIBIPC_PROJECT_DIR}/include/libipc/*.h
|
||||
${LIBIPC_PROJECT_DIR}/src/libipc/*.h
|
||||
${LIBIPC_PROJECT_DIR}/src/libipc/*.inc
|
||||
${LIBIPC_PROJECT_DIR}/src/libipc/circ/*.h
|
||||
${LIBIPC_PROJECT_DIR}/src/libipc/memory/*.h
|
||||
${LIBIPC_PROJECT_DIR}/src/libipc/platform/*.h
|
||||
${LIBIPC_PROJECT_DIR}/src/libipc/utility/*.h)
|
||||
|
||||
add_library(${PROJECT_NAME} SHARED ${SRC_FILES} ${HEAD_FILES})
|
||||
if(NOT MSVC)
|
||||
|
||||
@ -9,17 +9,17 @@ if(NOT MSVC)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/include
|
||||
${CMAKE_SOURCE_DIR}/src
|
||||
${CMAKE_SOURCE_DIR}/test
|
||||
${CMAKE_SOURCE_DIR}/3rdparty
|
||||
${CMAKE_SOURCE_DIR}/3rdparty/gtest/include)
|
||||
${LIBIPC_PROJECT_DIR}/include
|
||||
${LIBIPC_PROJECT_DIR}/src
|
||||
${LIBIPC_PROJECT_DIR}/test
|
||||
${LIBIPC_PROJECT_DIR}/3rdparty
|
||||
${LIBIPC_PROJECT_DIR}/3rdparty/gtest/include)
|
||||
|
||||
file(GLOB SRC_FILES ${CMAKE_SOURCE_DIR}/test/*.cpp)
|
||||
file(GLOB HEAD_FILES ${CMAKE_SOURCE_DIR}/test/*.h)
|
||||
file(GLOB SRC_FILES ${LIBIPC_PROJECT_DIR}/test/*.cpp)
|
||||
file(GLOB HEAD_FILES ${LIBIPC_PROJECT_DIR}/test/*.h)
|
||||
|
||||
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} tcmalloc_minimal)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user