Skip to content

Commit

Permalink
Regroup find_package calls in top level CMakeLists.
Browse files Browse the repository at this point in the history
  • Loading branch information
ldionne committed Mar 14, 2014
1 parent 9771367 commit f3d2ae1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
20 changes: 19 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ include(CMakeDependentOption)
option(MPL11_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
option(MPL11_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
option(MPL11_ENABLE_CXX0X "Use the -std=c++0x switch if the compiler supports it." ON)
option(MPL11_ENABLE_LIBCXX "Use the -stdlib=libc++ if the compiler supports it." ON)
CMAKE_DEPENDENT_OPTION(
MPL11_ENABLE_TESTS "Enable the `unit` target. To avoid target name conflicts and cluttering the list of targets, unit tests are disabled when the library is nested inside another project."
OFF "MPL11_IS_NESTED" # OFF when MPL11_IS_NESTED
Expand All @@ -39,8 +40,10 @@ CMAKE_DEPENDENT_OPTION(
# Check available compiler flags
#=============================================================================
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-ftemplate-backtrace-limit=0 MPL11_HAS_FTEMPLATE_BACKTRACE_LIMIT_0)
check_cxx_compiler_flag(-pedantic MPL11_HAS_PEDANTIC_FLAG)
check_cxx_compiler_flag(-std=c++0x MPL11_HAS_STDCXX0X_FLAG)
check_cxx_compiler_flag(-stdlib=libc++ MPL11_HAS_STDLIB_LIBCXX_FLAG)
check_cxx_compiler_flag(-W MPL11_HAS_W_FLAG)
check_cxx_compiler_flag(-Wall MPL11_HAS_WALL_FLAG)
check_cxx_compiler_flag(-Werror MPL11_HAS_WERROR_FLAG)
Expand All @@ -49,7 +52,6 @@ check_cxx_compiler_flag(-Wno-long-long MPL11_HAS_WNO_LONG_LONG_FLA
check_cxx_compiler_flag(-Wno-unused-local-typedefs MPL11_HAS_WNO_UNUSED_LOCAL_TYPEDEFS_FLAG)
check_cxx_compiler_flag(-Wno-unused-parameter MPL11_HAS_WNO_UNUSED_PARAMETER_FLAG)
check_cxx_compiler_flag(-Wwrite-strings MPL11_HAS_WWRITE_STRINGS_FLAG)
check_cxx_compiler_flag(-ftemplate-backtrace-limit=0 MPL11_HAS_FTEMPLATE_BACKTRACE_LIMIT_0)


#=============================================================================
Expand Down Expand Up @@ -86,6 +88,10 @@ if (MPL11_ENABLE_CXX0X AND MPL11_HAS_STDCXX0X_FLAG)
list(APPEND MPL11_CXX_FEATURE_FLAGS -std=c++0x)
endif()

if (MPL11_ENABLE_LIBCXX AND MPL11_HAS_STDLIB_LIBCXX_FLAG)
list(APPEND MPL11_CXX_FEATURE_FLAGS -stdlib=libc++)
endif()

# This is the only place where add_definitions is called. Other properties
# are set on a per-target basis.
add_definitions(
Expand All @@ -94,6 +100,18 @@ add_definitions(
)


#=============================================================================
# Search for packages.
#
# Behavior when the package is found or not is customized at the
# point where the package is required.
#=============================================================================
find_package(Boost)
find_package(Doxygen)
find_package(Gnuplot)
find_package(Ruby 2)


#=============================================================================
# Setup the library
#=============================================================================
Expand Down
3 changes: 1 addition & 2 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#=============================================================================
# Setup the documentation
#=============================================================================
find_package(Doxygen)
if (DOXYGEN_FOUND)
configure_file(Doxyfile.in Doxyfile @ONLY)
add_custom_target(
Expand All @@ -10,5 +9,5 @@ if (DOXYGEN_FOUND)
COMMENT "Generating API documentation with Doxygen" VERBATIM
)
else()
message(STATUS "Doxygen not found, the 'doc' target will be unavailable.")
message(STATUS "Doxygen not found; the 'doc' target will be unavailable.")
endif()
15 changes: 2 additions & 13 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,9 @@
#=============================================================================
# Setup examples
#=============================================================================
add_custom_target(example COMMENT "Build all the examples.")
add_custom_target(examples COMMENT "Build all the examples.")

function(mpl11_add_example name sources)
add_executable(${name} ${sources})
add_dependencies(example ${name})
add_dependencies(examples ${name})
endfunction()


#=============================================================================
# Setup examples requiring Boost
#=============================================================================
find_package(Boost QUIET)
if (NOT Boost_FOUND)
message(STATUS "Boost headers were not found. Some examples won't be available.")
else()

endif()

0 comments on commit f3d2ae1

Please sign in to comment.