forked from balp/arduino-mock
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from ikeyasu/cmake
Change build system to CMake
- Loading branch information
Showing
11 changed files
with
135 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
language: cpp | ||
sudo: false | ||
compiler: | ||
- gcc | ||
- gcc | ||
before_install: | ||
- sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ trusty main universe" | ||
- sudo apt-get update -qq | ||
- sudo apt-get install astyle=2.03-1 -qq | ||
# astyle-2.03 | ||
# downloading astyle-2.03 | ||
- mkdir -p .travis-tmp/astyle-2.03 | ||
- wget -P .travis-tmp/astyle-2.03/ http://heanet.dl.sourceforge.net/project/astyle/astyle/astyle%202.03/astyle_2.03_linux.tar.gz | ||
- tar xvzf .travis-tmp/astyle-2.03/astyle_2.03_linux.tar.gz -C .travis-tmp/astyle-2.03/ | ||
# build astyle-2.03 | ||
- pushd .travis-tmp/astyle-2.03/astyle/build/gcc && make && export PATH=`pwd`/bin:$PATH && popd | ||
# cmake-3.2.2 | ||
- mkdir -p .travis-tmp/cmake-3.2.2 | ||
- wget --no-check-certificate -P .travis-tmp/cmake-3.2.2/ https://cmake.org/files/v3.2/cmake-3.2.2-Linux-x86_64.sh | ||
- bash .travis-tmp/cmake-3.2.2/cmake-3.2.2-Linux-x86_64.sh --exclude-subdir --prefix=.travis-tmp/cmake-3.2.2 --skip-license | ||
- export PATH=`pwd`/.travis-tmp/cmake-3.2.2/bin:$PATH | ||
script: | ||
- pushd test && make test && popd | ||
- ./build.sh | ||
- ./script/travis_format_checcker.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
cmake_minimum_required (VERSION 2.8.8) | ||
project (arduino_mock) | ||
|
||
find_package(Threads REQUIRED) | ||
add_subdirectory(lib/gtest) | ||
add_subdirectory(lib/gmock) | ||
|
||
message ("building arduino_mock") | ||
message("Gtest include: ${GTEST_INCLUDE_DIRS}") | ||
message("Gmock include: ${GMOCK_INCLUDE_DIRS}") | ||
include_directories(${GTEST_INCLUDE_DIRS} ${GMOCK_INCLUDE_DIRS} include) | ||
file(GLOB SRC | ||
"src/ArduinoMockAll.cc" | ||
) | ||
|
||
add_library(arduino_mock STATIC ${SRC}) | ||
|
||
target_include_directories(arduino_mock | ||
PUBLIC "include" | ||
) | ||
|
||
target_link_libraries(arduino_mock | ||
${GTEST_LIBS_DIR}/libgtest.a | ||
${GMOCK_LIBS_DIR}/libgmock.a | ||
${CMAKE_THREAD_LIBS_INIT} | ||
) | ||
|
||
set_target_properties( arduino_mock | ||
PROPERTIES | ||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/dist/lib" | ||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/dist/lib" | ||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/dist/bin" | ||
) | ||
|
||
add_dependencies(arduino_mock gtest gmock) | ||
|
||
option(test "Build all tests." OFF) | ||
|
||
if (test) | ||
enable_testing() | ||
add_subdirectory(test) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
cd -- "$(dirname -- "$0")" | ||
mkdir -p build | ||
cd build | ||
cmake -Dtest=ON .. | ||
make | ||
ctest -V |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
cmake_minimum_required(VERSION 2.8.8) | ||
project(gmock_builder C CXX) | ||
include(ExternalProject) | ||
|
||
ExternalProject_Add(gmock | ||
URL https://googlemock.googlecode.com/files/gmock-1.7.0.zip | ||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gmock | ||
INSTALL_COMMAND "" | ||
) | ||
|
||
# Specify include dir | ||
ExternalProject_Get_Property(gmock source_dir) | ||
set(GMOCK_INCLUDE_DIRS ${source_dir}/include PARENT_SCOPE) | ||
|
||
# Specify MainTest's link libraries | ||
ExternalProject_Get_Property(gmock binary_dir) | ||
set(GMOCK_LIBS_DIR ${binary_dir} PARENT_SCOPE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
message("in gtest") | ||
project(gtest_builder C CXX) | ||
include(ExternalProject) | ||
|
||
ExternalProject_Add(gtest | ||
URL https://googletest.googlecode.com/files/gtest-1.7.0.zip | ||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gtest | ||
INSTALL_COMMAND "" | ||
) | ||
|
||
# Specify include dir | ||
ExternalProject_Get_Property(gtest source_dir) | ||
set(GTEST_INCLUDE_DIRS ${source_dir}/include PARENT_SCOPE) | ||
|
||
# Specify MainTest's link libraries | ||
ExternalProject_Get_Property(gtest binary_dir) | ||
set(GTEST_LIBS_DIR ${binary_dir} PARENT_SCOPE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
message ("building tests for Arduino Mock") | ||
# include_directories(${GTEST_INCLUDE_DIRS}) | ||
file(GLOB SRCS *.cc) | ||
|
||
add_executable(test_all test_all.cc) | ||
|
||
target_link_libraries(test_all | ||
arduino_mock | ||
${GTEST_LIBS_DIR}/libgtest.a | ||
${GTEST_LIBS_DIR}/libgtest_main.a | ||
${GMOCK_LIBS_DIR}/libgmock.a | ||
${CMAKE_THREAD_LIBS_INIT} | ||
) | ||
|
||
add_dependencies(test_all gtest) | ||
add_test(arduino_mock_test test_all) |
This file was deleted.
Oops, something went wrong.
Submodule gmock
deleted from
896ba0
Submodule googletest
deleted from
465055
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "Arduino_unittest.cc" | ||
#include "EEPROM_unittest.cc" | ||
#include "Serial_unittest.cc" | ||
#include "serialHelper_unittest.cc" | ||
#include "Spark_unittest.cc" | ||
#include "WiFi_unittest.cc" | ||
#include "Wire_unittest.cc" | ||
|
||
int main(int argc, char* argv[]) { | ||
::testing::InitGoogleTest(&argc, argv); | ||
return RUN_ALL_TESTS(); | ||
} |