using cmake for building test

This commit is contained in:
mutouyun 2019-01-01 14:04:55 +08:00
parent c52773efa9
commit feb1869e11
4 changed files with 57 additions and 26 deletions

View File

@ -27,10 +27,15 @@ before_install:
script: script:
- qmake -v - qmake -v
- cd ./build - cd ./build
- if [ $USING_CMAKE -eq 1 ]; then cmake -DCMAKE_BUILD_TYPE=Release CMakeLists.txt; else qmake -o Makefile ipc.pro QMAKE_CC=$CC QMAKE_CXX=$CXX QMAKE_LINK=$CXX; fi - if [ $USING_CMAKE -eq 1 ]; then
- qmake -o MakefileTest test.pro QMAKE_CC=$CC QMAKE_CXX=$CXX QMAKE_LINK=$CXX cmake -DCMAKE_BUILD_TYPE=Release CMakeLists.txt
- make make
- make -f MakefileTest else
qmake -o Makefile ipc.pro QMAKE_CC=$CC QMAKE_CXX=$CXX QMAKE_LINK=$CXX
qmake -o MakefileTest test.pro QMAKE_CC=$CC QMAKE_CXX=$CXX QMAKE_LINK=$CXX
make
make -f MakefileTest
fi
- export LD_LIBRARY_PATH=../output:$LD_LIBRARY_PATH && ../output/test - export LD_LIBRARY_PATH=../output:$LD_LIBRARY_PATH && ../output/test
notifications: notifications:

View File

@ -1,23 +1,3 @@
cmake_minimum_required(VERSION 3.10) cmake_minimum_required(VERSION 3.10)
project(ipc) project(cpp-ipc)
add_subdirectory(test)
add_compile_definitions(__IPC_LIBRARY__)
if(MSVC)
add_compile_options("/std:c++17")
else()
add_compile_options("-std=gnu++1z")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
endif()
include_directories("../include")
include_directories("../src")
if(UNIX)
file(GLOB DIR_SRCS ../src/platform/*_linux.cpp)
else()
file(GLOB DIR_SRCS ../src/platform/*_win.cpp)
endif()
aux_source_directory(../src DIR_SRCS)
add_library(ipc SHARED ${DIR_SRCS})
set(LIBRARY_OUTPUT_PATH ../output)

22
build/ipc/CMakeLists.txt Normal file
View File

@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.10)
project(ipc)
add_compile_definitions(__IPC_LIBRARY__)
if(MSVC)
add_compile_options(/std:c++17)
else()
add_compile_options(-std=gnu++1z)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
endif()
include_directories(../../include ../../src)
if(UNIX)
file(GLOB DIR_SRCS ../../src/platform/*_linux.cpp)
else()
file(GLOB DIR_SRCS ../../src/platform/*_win.cpp)
endif()
aux_source_directory(../../src DIR_SRCS)
add_library(ipc SHARED ${DIR_SRCS})
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/../output)

24
build/test/CMakeLists.txt Normal file
View File

@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.10)
project(test)
set(CMAKE_AUTOMOC ON)
find_package(Qt5Core)
find_package(Qt5Test)
if(MSVC)
add_compile_options(/std:c++17)
else()
add_compile_options(-std=gnu++1z -Wno-unused-function -Wno-attributes)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
endif()
include_directories(../../include ../../src ../../test ../../test/capo)
file(GLOB SRC_FILES "../../test/*.cpp")
file(GLOB HEAD_FILES "../../test/*.h")
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/../output)
link_directories(${EXECUTABLE_OUTPUT_PATH})
add_subdirectory(../ipc ipc.out)
add_executable(${PROJECT_NAME} ${SRC_FILES} ${HEAD_FILES})
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Test ipc)