diff --git a/CMakeLists.txt b/CMakeLists.txt index c10d4f292..af4d02524 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ include(RegisterSourceGroup) include(imported) include(CheckCXXSourceCompiles) include(CheckCSourceCompiles) +include(ProcessorCount) ############################################################# ## @@ -84,6 +85,17 @@ set(ADDITIONAL_LINK_DIRS "" CACHE STRING "Additional directories added to the li set(USE_XERCESC ${XML_SUPPORT}) mark_as_advanced(USE_XERCESC) +# Get an approximation of the number of available processors (used for parallel build of shipped resources) +ProcessorCount(STORM_RESOURCES_BUILD_JOBCOUNT_DEFAULT) +# To be safe, we only take a little more than half of the resources. +# This also correctly deals with the case where ProcessorCount is unable to find the correct number (and thus returns 0) +MATH(EXPR STORM_RESOURCES_BUILD_JOBCOUNT_DEFAULT "${STORM_RESOURCES_BUILD_JOBCOUNT_DEFAULT}/2 + 1") +set(STORM_RESOURCES_BUILD_JOBCOUNT "${STORM_RESOURCES_BUILD_JOBCOUNT_DEFAULT}" CACHE STRING "The number of jobs used when building external resources") +mark_as_advanced(STORM_RESOURCES_BUILD_JOBCOUNT) +if(NOT STORM_RESOURCES_BUILD_JOBCOUNT GREATER 0) + message(FATAL_ERROR "STORM_RESOURCES_BUILD_JOBCOUNT must be a positive number. Got '${STORM_RESOURCES_BUILD_JOBCOUNT}' instead." ) +endif() + # Set some CMAKE Variables as advanced mark_as_advanced(CMAKE_OSX_ARCHITECTURES) mark_as_advanced(CMAKE_OSX_SYSROOT) diff --git a/resources/3rdparty/CMakeLists.txt b/resources/3rdparty/CMakeLists.txt index cdc18db60..6bfd018ea 100644 --- a/resources/3rdparty/CMakeLists.txt +++ b/resources/3rdparty/CMakeLists.txt @@ -5,6 +5,7 @@ set(STORM_3RDPARTY_SOURCE_DIR ${PROJECT_SOURCE_DIR}/resources/3rdparty) set(STORM_3RDPARTY_BINARY_DIR ${PROJECT_BINARY_DIR}/resources/3rdparty) set(STORM_3RDPARTY_INCLUDE_DIR ${PROJECT_BINARY_DIR}/include/resources/3rdparty) +message(STATUS "Storm - Building external resources with ${STORM_RESOURCES_BUILD_JOBCOUNT} job(s) in parallel.") ############################################################# ## @@ -338,7 +339,7 @@ if (STORM_SHIPPED_CARL) CONFIGURE_COMMAND "" BUILD_IN_SOURCE 1 BUILD_COMMAND make lib_carl - INSTALL_COMMAND make install + INSTALL_COMMAND make install -j${STORM_RESOURCES_BUILD_JOBCOUNT} LOG_BUILD ON LOG_INSTALL ON BUILD_BYPRODUCTS ${STORM_3RDPARTY_BINARY_DIR}/carl/lib/libcarl${DYNAMIC_EXT} diff --git a/resources/3rdparty/include_cudd.cmake b/resources/3rdparty/include_cudd.cmake index 6ed57d456..16b045306 100644 --- a/resources/3rdparty/include_cudd.cmake +++ b/resources/3rdparty/include_cudd.cmake @@ -54,7 +54,7 @@ ExternalProject_Add( PATCH_COMMAND ${AUTORECONF} CONFIGURE_COMMAND ${STORM_3RDPARTY_SOURCE_DIR}/cudd-3.0.0/configure --enable-shared --enable-obj --with-pic=yes --prefix=${STORM_3RDPARTY_BINARY_DIR}/cudd-3.0.0 --libdir=${CUDD_LIB_DIR} CC=${CMAKE_C_COMPILER} CXX=${CUDD_CXX_COMPILER} ${CUDD_INCLUDE_FLAGS} BUILD_COMMAND make ${STORM_CUDD_FLAGS} - INSTALL_COMMAND make install + INSTALL_COMMAND make install -j${STORM_RESOURCES_BUILD_JOBCOUNT} BUILD_IN_SOURCE 0 LOG_CONFIGURE ON LOG_BUILD ON diff --git a/resources/3rdparty/include_glpk.cmake b/resources/3rdparty/include_glpk.cmake index 87c3ebcfa..b2aef3dad 100644 --- a/resources/3rdparty/include_glpk.cmake +++ b/resources/3rdparty/include_glpk.cmake @@ -17,7 +17,7 @@ else() SOURCE_DIR ${STORM_3RDPARTY_SOURCE_DIR}/glpk-4.65 CONFIGURE_COMMAND ${STORM_3RDPARTY_SOURCE_DIR}/glpk-4.65/configure --prefix=${STORM_3RDPARTY_BINARY_DIR}/glpk-4.65 --libdir=${GLPK_LIB_DIR} CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER} ${GLPK_INCLUDE_FLAGS} BUILD_COMMAND make "CFLAGS=-O3 -w" - INSTALL_COMMAND make install + INSTALL_COMMAND make install -j${STORM_RESOURCES_BUILD_JOBCOUNT} BUILD_IN_SOURCE 0 LOG_CONFIGURE ON LOG_BUILD ON diff --git a/resources/3rdparty/include_spot.cmake b/resources/3rdparty/include_spot.cmake index d05f10b85..e7c138b2c 100644 --- a/resources/3rdparty/include_spot.cmake +++ b/resources/3rdparty/include_spot.cmake @@ -30,7 +30,7 @@ if(STORM_USE_SPOT_SHIPPED AND NOT STORM_HAVE_SPOT) SOURCE_DIR ${STORM_3RDPARTY_BINARY_DIR}/spot_src PREFIX ${STORM_3RDPARTY_BINARY_DIR}/spot CONFIGURE_COMMAND ${STORM_3RDPARTY_BINARY_DIR}/spot_src/configure --prefix=${STORM_3RDPARTY_BINARY_DIR}/spot --disable-python - BUILD_COMMAND make -j1 + BUILD_COMMAND make -j${STORM_RESOURCES_BUILD_JOBCOUNT} INSTALL_COMMAND make install LOG_CONFIGURE ON LOG_BUILD ON