From baca1acfc686b344259e4c891fb2c303de94aa15 Mon Sep 17 00:00:00 2001 From: Paul Colby Date: Thu, 26 Dec 2013 21:45:39 +1100 Subject: [PATCH] Issue #2 Replaced temporary example Makefiles with cmake equivalents. --- .gitignore | 1 + .travis.yml | 6 ++++-- example/CMakeLists.txt | 7 +++++++ example/Makefile | 8 -------- example/simple/CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ example/simple/Makefile | 18 ------------------ example/simplecpu/CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ example/simplecpu/Makefile | 18 ------------------ example/trivial/CMakeLists.txt | 31 +++++++++++++++++++++++++++++++ example/trivial/Makefile | 18 ------------------ 10 files changed, 105 insertions(+), 64 deletions(-) create mode 100644 example/CMakeLists.txt delete mode 100644 example/Makefile create mode 100644 example/simple/CMakeLists.txt delete mode 100644 example/simple/Makefile create mode 100644 example/simplecpu/CMakeLists.txt delete mode 100644 example/simplecpu/Makefile create mode 100644 example/trivial/CMakeLists.txt delete mode 100644 example/trivial/Makefile diff --git a/.gitignore b/.gitignore index bbe69da..1692a2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +build pmda-cpp.config pmda-cpp.creator pmda-cpp.creator.user diff --git a/.travis.yml b/.travis.yml index 06b3754..ff37545 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ install: - sudo apt-get install -qq libboost-program-options-dev libpcp3 libpcp3-dev libpcp-pmda3 libpcp-pmda3-dev before_script: - - mkdir -p test/unit/build + - mkdir -p example/build test/unit/build script: # Run the unit tests. @@ -19,4 +19,6 @@ script: - cmake .. && make check - popd # Ensure the examples compile cleanly. - - make -C example + - pushd example/build + - cmake .. + - popd diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt new file mode 100644 index 0000000..0c1edad --- /dev/null +++ b/example/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.6 FATAL_ERROR) + +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}) + +add_subdirectory(simple) +add_subdirectory(simplecpu) +add_subdirectory(trivial) diff --git a/example/Makefile b/example/Makefile deleted file mode 100644 index 97b35ae..0000000 --- a/example/Makefile +++ /dev/null @@ -1,8 +0,0 @@ - -EXAMPLES=$(shell find . -maxdepth 1 -mindepth 1 -type d) - -all: - @for EXAMPLE in $(EXAMPLES); do $(MAKE) -C "$$EXAMPLE" || exit $?; done - -clean: - @for EXAMPLE in $(EXAMPLES); do $(MAKE) -C "$$EXAMPLE" clean || true; done diff --git a/example/simple/CMakeLists.txt b/example/simple/CMakeLists.txt new file mode 100644 index 0000000..efdd393 --- /dev/null +++ b/example/simple/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required (VERSION 2.6 FATAL_ERROR) + +project(simple) + +include_directories ("${PROJECT_SOURCE_DIR}/../../include") + +add_executable("pmda${PROJECT_NAME}" "${PROJECT_NAME}.cpp") +add_executable("pmda${PROJECT_NAME}-noboost" "${PROJECT_NAME}.cpp") + +target_link_libraries("pmda${PROJECT_NAME}" pcp pcp_pmda boost_program_options) +target_link_libraries("pmda${PROJECT_NAME}-noboost" pcp pcp_pmda) + +set_property( + TARGET "pmda${PROJECT_NAME}-noboost" + PROPERTY COMPILE_DEFINITIONS PCP_CPP_NO_BOOST +) + +# Enable (and stop on) compiler warnings. +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag(-Wall HAVE_WALL) +check_cxx_compiler_flag(-Werror HAVE_WERROR) +check_cxx_compiler_flag(-Wextra HAVE_WEXTRA) +if (HAVE_WALL) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +endif() +if (HAVE_WERROR) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +endif() +if (HAVE_WEXTRA) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") +endif() diff --git a/example/simple/Makefile b/example/simple/Makefile deleted file mode 100644 index 3a0ecfa..0000000 --- a/example/simple/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# Temporary Makefile. This will be replaced with a more -# robust example sometime. - -IAM = simple - -CXXFLAGS = -I../../include -O3 -Wall -Werror -Wextra -LDLIBS = -lpcp -lpcp_pmda - -all: pmda$(IAM) pmda$(IAM)-noboost - -pmda$(IAM): $(IAM).cpp ../../include/pcp-cpp/*.hpp - $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $< $(LDLIBS) -lboost_program_options -o $@ - -pmda$(IAM)-noboost: $(IAM).cpp ../../include/pcp-cpp/*.hpp - $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $< $(LDLIBS) -DPCP_CPP_NO_BOOST -o $@ - -clean: - rm -f pmda$(IAM) pmda$(IAM)-noboost pmda_$(IAM).so diff --git a/example/simplecpu/CMakeLists.txt b/example/simplecpu/CMakeLists.txt new file mode 100644 index 0000000..500ec42 --- /dev/null +++ b/example/simplecpu/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required (VERSION 2.6 FATAL_ERROR) + +project(simplecpu) + +include_directories ("${PROJECT_SOURCE_DIR}/../../include") + +add_executable("pmda${PROJECT_NAME}" "${PROJECT_NAME}.cpp") +add_executable("pmda${PROJECT_NAME}-noboost" "${PROJECT_NAME}.cpp") + +target_link_libraries("pmda${PROJECT_NAME}" pcp pcp_pmda boost_program_options) +target_link_libraries("pmda${PROJECT_NAME}-noboost" pcp pcp_pmda) + +set_property( + TARGET "pmda${PROJECT_NAME}-noboost" + PROPERTY COMPILE_DEFINITIONS PCP_CPP_NO_BOOST +) + +# Enable (and stop on) compiler warnings. +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag(-Wall HAVE_WALL) +check_cxx_compiler_flag(-Werror HAVE_WERROR) +check_cxx_compiler_flag(-Wextra HAVE_WEXTRA) +if (HAVE_WALL) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +endif() +if (HAVE_WERROR) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +endif() +if (HAVE_WEXTRA) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") +endif() diff --git a/example/simplecpu/Makefile b/example/simplecpu/Makefile deleted file mode 100644 index f4300a2..0000000 --- a/example/simplecpu/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# Temporary Makefile. This will be replaced with a more -# robust example sometime. - -IAM = simplecpu - -CXXFLAGS = -I../../include -O3 -Wall -Werror -Wextra -LDLIBS = -lpcp -lpcp_pmda - -all: pmda$(IAM) pmda$(IAM)-noboost - -pmda$(IAM): $(IAM).cpp ../../include/pcp-cpp/*.hpp - $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $< $(LDLIBS) -lboost_program_options -o $@ - -pmda$(IAM)-noboost: $(IAM).cpp ../../include/pcp-cpp/*.hpp - $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $< $(LDLIBS) -DPCP_CPP_NO_BOOST -o $@ - -clean: - rm -f pmda$(IAM) pmda$(IAM)-noboost pmda_$(IAM).so diff --git a/example/trivial/CMakeLists.txt b/example/trivial/CMakeLists.txt new file mode 100644 index 0000000..c10ef29 --- /dev/null +++ b/example/trivial/CMakeLists.txt @@ -0,0 +1,31 @@ +cmake_minimum_required (VERSION 2.6 FATAL_ERROR) + +project(trivial) + +include_directories ("${PROJECT_SOURCE_DIR}/../../include") + +add_executable("pmda${PROJECT_NAME}" "${PROJECT_NAME}.cpp") +add_executable("pmda${PROJECT_NAME}-noboost" "${PROJECT_NAME}.cpp") + +target_link_libraries("pmda${PROJECT_NAME}" pcp pcp_pmda boost_program_options) +target_link_libraries("pmda${PROJECT_NAME}-noboost" pcp pcp_pmda) + +set_property( + TARGET "pmda${PROJECT_NAME}-noboost" + PROPERTY COMPILE_DEFINITIONS PCP_CPP_NO_BOOST +) + +# Enable (and stop on) compiler warnings. +include(CheckCXXCompilerFlag) +check_cxx_compiler_flag(-Wall HAVE_WALL) +check_cxx_compiler_flag(-Werror HAVE_WERROR) +check_cxx_compiler_flag(-Wextra HAVE_WEXTRA) +if (HAVE_WALL) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") +endif() +if (HAVE_WERROR) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +endif() +if (HAVE_WEXTRA) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") +endif() diff --git a/example/trivial/Makefile b/example/trivial/Makefile deleted file mode 100644 index f50d2c3..0000000 --- a/example/trivial/Makefile +++ /dev/null @@ -1,18 +0,0 @@ -# Temporary Makefile. This will be replaced with a more -# robust example sometime. - -IAM = trivial - -CXXFLAGS = -I../../include -O3 -Wall -Werror -Wextra -LDLIBS = -lpcp -lpcp_pmda - -all: pmda$(IAM) pmda$(IAM)-noboost - -pmda$(IAM): $(IAM).cpp ../../include/pcp-cpp/*.hpp - $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $< $(LDLIBS) -lboost_program_options -o $@ - -pmda$(IAM)-noboost: $(IAM).cpp ../../include/pcp-cpp/*.hpp - $(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) $< $(LDLIBS) -DPCP_CPP_NO_BOOST -o $@ - -clean: - rm -f pmda$(IAM) pmda$(IAM)-noboost pmda_$(IAM).so