Skip to content

Commit

Permalink
0.7 RC (#56)
Browse files Browse the repository at this point in the history
* overhaul of build system (#54)

* overhaul of build system
every folder has CMakeLists.txt for modularity
examples/ excluded from default make
one config.h for all targets
fix olaclient.c #include <ola/OlaClientWrapper.h>

* update build sequence
exclude PCA9685test from default make

* merging master changes back into develop

* removed warning about BSD_SOURCES

* update to master branch netinst scripts

* examples/CMakeLists.txt: target "examples"
examples code comments for required pkgs

* apt-get pkgs required by examples, make examples
  • Loading branch information
edlins authored May 26, 2018
1 parent d0abff1 commit 3c11fac
Show file tree
Hide file tree
Showing 17 changed files with 60 additions and 81 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ branches:
before_install:
- sudo add-apt-repository -y ppa:voltvisionfrenchy/ola
- sudo apt-get update
- sudo apt-get install -y libola-dev
- sudo apt-get install -y --no-install-recommends libola-dev
- sudo apt-get install -y --no-install-recommends libncurses5-dev


before_script:
- mkdir build
- cd build
- cmake ..

script: make && make olaclient && sudo make install && ctest -V
script: make && sudo make install && make PCA9685test && ctest -V && make examples
65 changes: 20 additions & 45 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,55 +1,30 @@
cmake_minimum_required(VERSION 3.0)
project(PCA9685)
project(libPCA9685)

# set the lib version
set (libPCA9685_VERSION_MAJOR 0)
set (libPCA9685_VERSION_MINOR 7)
set(libPCA9685_VERSION_MAJOR 0)
set(libPCA9685_VERSION_MINOR 7)

# save the lib version in config.h
configure_file(config.h.cmake ${PROJECT_BINARY_DIR}/config.h)

# include for config.h
include_directories(${PROJECT_BINARY_DIR})

# add flags
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -D_BSD_SOURCE -std=c11 -Wall -pedantic -Wextra")
set(CMAKE_C_FLAGS "${CMAKE_CXX_FLAGS} -D_BSD_SOURCE -D_DEFAULT_SOURCE -std=c11 -Wall -pedantic -Wextra")

# build the library
add_subdirectory(src)

# build the test app
add_subdirectory(test EXCLUDE_FROM_ALL)

# build the examples, but not by default
add_subdirectory(examples EXCLUDE_FROM_ALL)

# add tests
enable_testing()
add_test(run_test sh -xc "./PCA9685test -td 1 40 > PCA9685_actual_output" 2>&1)
add_test(run_test sh -xc "./test/PCA9685test -td 1 40 > PCA9685_actual_output" 2>&1)
add_test(diff_output sh -xc "diff ../test/PCA9685_expected_output ./PCA9685_actual_output" 2>&1)


# build the library
add_subdirectory (src)
include_directories ("${PROJECT_SOURCE_DIR}/src")


# build the quickstart example
configure_file (
"${PROJECT_SOURCE_DIR}/examples/quickstart/quickstartConfig.h.in"
"${PROJECT_BINARY_DIR}/examples/quickstart/quickstartConfig.h"
)
include_directories("${PROJECT_BINARY_DIR}/examples/quickstart")
add_executable (quickstart examples/quickstart/quickstart.c)
target_link_libraries (quickstart PCA9685)


# build the PCA9685demo example
configure_file (
"${PROJECT_SOURCE_DIR}/examples/PCA9685demo/PCA9685demoConfig.h.in"
"${PROJECT_BINARY_DIR}/examples/PCA9685demo/PCA9685demoConfig.h"
)
include_directories("${PROJECT_BINARY_DIR}/examples/PCA9685demo")
add_executable (PCA9685demo examples/PCA9685demo/PCA9685demo.c)
target_link_libraries (PCA9685demo PCA9685)
target_link_libraries (PCA9685demo ncurses)


# build the PCA9685test app
configure_file (
"${PROJECT_SOURCE_DIR}/test/PCA9685testConfig.h.in"
"${PROJECT_BINARY_DIR}/test/PCA9685testConfig.h"
)
include_directories("${PROJECT_BINARY_DIR}/test")
add_executable (PCA9685test test/PCA9685test.c)
target_link_libraries (PCA9685test PCA9685)


# build the olaclient app
add_subdirectory(examples/olaclient)
include_directories("${PROJECT_BINARY_DIR}/examples/olaclient")
File renamed without changes.
8 changes: 8 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
project (examples)
# build the examples
add_subdirectory (olaclient)
add_subdirectory (PCA9685demo)
add_subdirectory (quickstart)

add_custom_target(examples)
add_dependencies(examples olaclient PCA9685demo quickstart)
4 changes: 4 additions & 0 deletions examples/PCA9685demo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
project (PCA9685demo)
add_executable(PCA9685demo PCA9685demo.c)
target_link_libraries(PCA9685demo PCA9685)
target_link_libraries(PCA9685demo ncurses)
4 changes: 2 additions & 2 deletions examples/PCA9685demo/PCA9685demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
#include <sys/time.h>
#include <signal.h>
#include <unistd.h>
#include <ncurses.h>
#include <ncurses.h> // sudo apt-get install libncurses5-dev
#include <getopt.h>
#include <limits.h>

#include <PCA9685.h>
#include "PCA9685demoConfig.h"
#include "config.h"


// globals
Expand Down
11 changes: 1 addition & 10 deletions examples/olaclient/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
cmake_minimum_required(VERSION 3.0)
project (olaclient)

set (libPCA9685_VERSION_MAJOR 0)
set (libPCA9685_VERSION_MINOR 7)
configure_file (
"${PROJECT_SOURCE_DIR}/olaclientConfig.h.in"
"${PROJECT_BINARY_DIR}/olaclientConfig.h"
)
include_directories ("${PROJECT_BINARY_DIR}")
include_directories ("${PROJECT_SOURCE_DIR}")

add_executable(olaclient EXCLUDE_FROM_ALL olaclient.cpp)
add_executable(olaclient olaclient.cpp)

target_link_libraries(olaclient PCA9685)
target_link_libraries(olaclient ola)
Expand Down
6 changes: 3 additions & 3 deletions examples/olaclient/olaclient.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include <ola/DmxBuffer.h>
#include <ola/DmxBuffer.h> // sudo apt-get install libola-dev
#include <ola/Logging.h>
#include <ola/client/ClientWrapper.h>
#include <ola/OlaClientWrapper.h>
#include <string>
#include <bitset>
#include <ctime>
using namespace std;

#include <PCA9685.h>
#include "olaclientConfig.h"
#include "config.h"

#define PWM_FREQ 200
#define DMX_UNIVERSE 1
Expand Down
2 changes: 0 additions & 2 deletions examples/olaclient/olaclientConfig.h.in

This file was deleted.

3 changes: 3 additions & 0 deletions examples/quickstart/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
project (quickstart)
add_executable(quickstart quickstart.c)
target_link_libraries(quickstart PCA9685)
2 changes: 1 addition & 1 deletion examples/quickstart/quickstart.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <stdbool.h>

#include <PCA9685.h>
#include "quickstartConfig.h"
#include "config.h"

int fd;
int addr = 0x40;
Expand Down
2 changes: 0 additions & 2 deletions examples/quickstart/quickstartConfig.h.in

This file was deleted.

15 changes: 5 additions & 10 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
cmake_minimum_required(VERSION 3.0)
project (libPCA9685)
project(libPCA9685)

set (libPCA9685_VERSION_MAJOR 0)
set (libPCA9685_VERSION_MINOR 7)
configure_file (
"${PROJECT_SOURCE_DIR}/libPCA9685Config.h.in"
"${PROJECT_BINARY_DIR}/libPCA9685Config.h"
)
include_directories ("${PROJECT_BINARY_DIR}")
# build the lib
add_library(PCA9685 SHARED PCA9685.c)

install (TARGETS PCA9685 DESTINATION lib)
install (FILES PCA9685.h DESTINATION include)
# install the lib
install(TARGETS PCA9685 DESTINATION lib)
install(FILES PCA9685.h DESTINATION include)
2 changes: 1 addition & 1 deletion src/PCA9685.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

// set the lib version from the Config header
// sets libPCA9685_VERSION_MAJOR and libPCA9685_VERSION_MINOR
#include "libPCA9685Config.h"
#include "config.h"

// debug flag
bool _PCA9685_DEBUG = 0;
Expand Down
2 changes: 0 additions & 2 deletions src/libPCA9685Config.h.in

This file was deleted.

8 changes: 8 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.0)
project(PCA9685test)

# build the test app
add_executable(PCA9685test PCA9685test.c)

# link with the lib
target_link_libraries(PCA9685test PCA9685)
2 changes: 1 addition & 1 deletion test/PCA9685test.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <stdbool.h>

#include <PCA9685.h>
#include "PCA9685testConfig.h"
#include "config.h"

int adpt;
int addr;
Expand Down

0 comments on commit 3c11fac

Please sign in to comment.