-
Notifications
You must be signed in to change notification settings - Fork 6
Building
Paul Colby edited this page Dec 26, 2013
·
10 revisions
PMDA++ doesn't actually need building... it's a header-only library. However, the project does includes a few buildable components - some examples, and tests. Building these follows the usual cmake build process:
- Create an out-of-tree build directory.
- Run
cmake
- Run
make
and/ormake check
For example:
mkdir ~/some/temp/build
cd ~/some/temp/build
cmake /path/to/source/checkout
make check
Building PMDAs build on the PMDA++ library should be quite easy. A typical CMakeList.txt
file would look like:
make_minimum_required (VERSION 2.6 FATAL_ERROR)
project(mypmda)
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
)
I'd also recommend enabling compiler warnings, such as:
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()
See the any of the following for some additional examples / inspiration: