Commit 91dce530 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Declared all custom build options in CMakeLists.txt

This way they can use either yes/no, on/off, or true/false.
parent 0766283e
Loading
Loading
Loading
Loading
+45 −25
Original line number Diff line number Diff line
@@ -18,6 +18,16 @@ project( tnl )

set( tnlVersion "0.1" )

# declare all custom build options
option(WITH_MIC "Build with MIC support" OFF)
option(WITH_CUDA "Build with CUDA support" ON)
set(WITH_CUDA_ARCH "auto" CACHE STRING "Build for these CUDA architectures")
option(WITH_OPENMP "Build with OpenMP support" ON)
option(WITH_TESTS "Build tests" ON)
option(WITH_COVERAGE "Enable code coverage reports from unit tests" OFF)
option(WITH_EXAMPLES "Compile the 'examples' directory" ON)
option(WITH_TEMPLATES_INSTANTIATION "Enable explicit template instantiation" OFF)

# install paths relative to the cmake's prefix
set( TNL_TARGET_INCLUDE_DIRECTORY "include/TNL" )
set( TNL_TARGET_DATA_DIRECTORY "share/TNL" )
@@ -65,12 +75,12 @@ if( CXX_COMPILER_NAME MATCHES "icpc" )
   #####
   #  Ckeck for MIC 
   #
   if( WITH_MIC STREQUAL "yes" )
       message( "Compile MIC support..."    )
   if( ${WITH_MIC} )
      message( "Enabled MIC support." )
      set( MIC_CXX_FLAGS "-DHAVE_MIC")
      # build all tests with MIC support
      set( CXX_TESTS_FLAGS ${CXX_TESTS_FLAGS} -DHAVE_MIC )
       set( WITH_CUDA "no")
      set( WITH_CUDA OFF CACHE BOOL "Build with CUDA support" )
   else()
      set( MIC_CXX_FLAGS "")
   endif()
@@ -89,7 +99,7 @@ endif()
#####
# Check for CUDA
#
if( WITH_CUDA STREQUAL "yes" )
if( ${WITH_CUDA} )
    find_package( CUDA )
    if( CUDA_FOUND )
        set( BUILD_CUDA TRUE)
@@ -164,7 +174,7 @@ if( WITH_CUDA STREQUAL "yes" )
        ####
        # Check for CUSPARSE
        #
        if( NOT WITH_CUSPARSE STREQUAL "no" )
        if( WITH_CUSPARSE )
           find_path( CUSPARSE_INCLUDE_DIR cusparse.h
                      /usr/local/cuda/include
                      ${CUDA_INCLUDE_DIR}
@@ -178,16 +188,16 @@ if( WITH_CUDA STREQUAL "yes" )
               cuda_include_directories( ${CUSPARSE_INCLUDE_DIR} )
               set( CUSPARSE_LIBRARY "${CUDA_cusparse_LIBRARY}" )
           endif()
        endif( NOT WITH_CUSPARSE STREQUAL "no" )        
    endif( CUDA_FOUND )
endif( WITH_CUDA STREQUAL "yes" )
        endif()
    endif()
endif()


####
# Check for OpenMP
#
if( OPENMP_FOUND AND WITH_OPENMP STREQUAL "yes" )
   message( "Compiler supports OpenMP." )
if( OPENMP_FOUND AND ${WITH_OPENMP} )
   message( "Enabled OpenMP support." )
   set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_OPENMP ${OpenMP_CXX_FLAGS}" )
endif()

@@ -271,17 +281,17 @@ else()
    set( HAVE_SYS_IOCTL_H "#define HAVE_SYS_IOCTL_H 1" )
endif()

if( WITH_TESTS STREQUAL "yes" )
if( ${WITH_TESTS} )
   enable_testing()

   # build gtest libs
   include( BuildGtest )

   if( WITH_COVERAGE STREQUAL "yes" AND CMAKE_BUILD_TYPE STREQUAL "Debug" )
   if( ${WITH_COVERAGE} AND CMAKE_BUILD_TYPE STREQUAL "Debug" )
      # enable code coverage reports
      include( UseCodeCoverage )
   endif()
endif( WITH_TESTS STREQUAL "yes" )
endif()

#if( BUILD_MPI )
#   FIND_PATH( PETSC_INCLUDE_DIR petsc.h
@@ -311,7 +321,7 @@ endif( WITH_TESTS STREQUAL "yes" )
####
# Explicit template instantiation
#
#if( WITH_TEMPLATE_INSTANTIATION STREQUAL "yes" )
#if( ${WITH_TEMPLATE_INSTANTIATION} )
#   AddCompilerFlag( "-DTEMPLATE_EXPLICIT_INSTANTIATION " )
#
#   if( INSTANTIATE_INT STREQUAL "yes" )
@@ -352,7 +362,7 @@ add_subdirectory( src )
add_subdirectory( share )
add_subdirectory( tests )

if( WITH_EXAMPLES STREQUAL "yes" )
if( ${WITH_EXAMPLES} )
   add_subdirectory( examples )
endif()

@@ -384,6 +394,16 @@ set(CPACK_SOURCE_STRIP_FILES "Release")
#set(CPACK_PACKAGE_EXECUTABLES "MyExecutable" "My Executable")
INCLUDE( CPack )

# Print custom build options
message( "-- Build options:" )
message( "   WITH_MIC=${WITH_MIC}" )
message( "   WITH_CUDA=${WITH_CUDA}" )
message( "   WITH_CUDA_ARCH=${WITH_CUDA_ARCH}" )
message( "   WITH_OPENMP=${WITH_OPENMP}" )
message( "   WITH_TESTS=${WITH_TESTS}" )
message( "   WITH_COVERAGE=${WITH_COVERAGE}" )
message( "   WITH_EXAMPLES=${WITH_EXAMPLES}" )
message( "   WITH_TEMPLATES_INSTANTIATION=${WITH_TEMPLATES_INSTANTIATION}" )
# Print compiler options
message( "-- Compiler options:" )
message( "   CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}" )
+1 −1
Original line number Diff line number Diff line
add_subdirectory( Arithmetics )
if( WITH_EXAMPLES STREQUAL "yes" )
if( ${WITH_EXAMPLES} )
   add_subdirectory( Hamilton-Jacobi )
endif()
+2 −2
Original line number Diff line number Diff line
if( WITH_TESTS STREQUAL "yes" )
if( ${WITH_TESTS} )

ADD_SUBDIRECTORY( Containers )
ADD_SUBDIRECTORY( Matrices )
@@ -41,4 +41,4 @@ ADD_TEST( StringTest ${EXECUTABLE_OUTPUT_PATH}/StringTest${CMAKE_EXECUTABLE_SUFF
ADD_TEST( ObjectTest ${EXECUTABLE_OUTPUT_PATH}/ObjectTest${CMAKE_EXECUTABLE_SUFFIX} )
ADD_TEST( UniquePointerTest ${EXECUTABLE_OUTPUT_PATH}/UniquePointerTest${CMAKE_EXECUTABLE_SUFFIX} )

endif( WITH_TESTS STREQUAL "yes" )
endif( ${WITH_TESTS} )