Commit 237c2f9a authored by Martin Beseda's avatar Martin Beseda

ENH: Simplified building system + added automatic Boost detection.

parent 8770eecd
......@@ -31,11 +31,6 @@ if(CMAKE_BUILD_TYPE MATCHES DEBUG)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
# Processing user variables
if (WITH_TIME_PROFILING)
add_definitions(-DTIME_PROFILING)
endif()
# C & CXX compilers
if (WIN32)
set (CMAKE_C_COMPILER gcc)
......@@ -52,6 +47,19 @@ file(APPEND compilers.env "export CC=${CMAKE_C_COMPILER}\n")
set(SRC_DIR src)
set(PROJECT_BINARY_DIR build)
#-------------------------#
# Find external libraries #
#-------------------------#
set(Boost_USE_MULTITHREADED ON)
find_package(Boost REQUIRED COMPONENTS serialization random)
if(Boost_FOUND)
message("Boost INCLUDE DIR: ${Boost_INCLUDE_DIRS}")
message("Boost LIB DIR: ${Boost_LIBRARY_DIRS}")
include_directories(${Boost_INCLUDE_DIRS})
endif()
#find_package(exprt) #TODO write FindExprt.cmake script
#--------------------#
# Building libraries #
#--------------------#
......@@ -63,9 +71,9 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
add_subdirectory(${SRC_DIR} ${PROJECT_BINARY_DIR})
message ("Current directory:" ${PWD})
message ("Current directory:" ${CMAKE_CURRENT_SOURCE_DIR})
message ("SRC_DIR: " ${SRC_DIR})
message ("BUILD_DIR:" ${BUILD_DIR})
message ("BUILD_DIR:" ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
if (WIN32)
message ("Windows")
......@@ -73,8 +81,13 @@ else ()
message ("Not Windows")
endif ()
#find_package(Boost COMPONENTS unit_test_framework REQUIRED)
IF (Boost_FOUND)
message("Boost DIR: " ${Boost_INCLUDE_DIR})
include_directories(${Boost_INCLUDE_DIR})
#TODO implement to utilize a maximum number of threads for OpenMP
include(ProcessorCount)
ProcessorCount(n_cores)
if(NOT n_cores EQUAL 0)
message("Build will be performed on ${n_cores} cores.")
set(CTEST_BUILD_FLAGS -j${N})
set(ENV{N_CORES} ${N})
set(ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N})
endif()
......@@ -9,67 +9,10 @@
# FORTRAN_COMPILER=gfortran
# Build type (Release/Debug)
BUILD_TYPE=Debug
# Turn of/off time profiling (1/0)
WITH_TIME_PROFILIN=1
CPP_COMPILER=g++
#--------------#----------------------------------------------------------
# Library path #
#--------------#
MAKEFILE_TYPE=""
LIB_PATH="$PWD/build/lib"
#LIB_PATH_WIN="$CD\\build\\lib"
echo ${LIB_PATH}
#echo ${LIB_PATH_WIN}
case `uname -s` in
Darwin)
echo 'OS X is not supported yet...'
exit -1
;;
Linux)
MAKEFILE_TYPE="Unix Makefiles"
if [[ ${LD_LIBRARY_PATH} != *${LIB_PATH}* ]]; then
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${LIB_PATH}
fi
;;
CYGWIN*)
MAKEFILE_TYPE="Unix Makefiles"
# if [[ ${PATH} != *${LIB_PATH_WIN}* ]]; then
# export PATH=${PATH};${LIB_PATH_WIN}
# fi
;;
MINGW*)
MAKEFILE_TYPE="MinGW Makefiles"
# if [[ ${PATH} != *${LIB_PATH_WIN}* ]]; then
# export PATH=${PATH};${LIB_PATH_WIN}
# fi
;;
MSYS*)
MAKEFILE_TYPE="MSYS Makefiles"
echo ${MAKEFILE_TYPE}
# if [[ ${PATH} != *${LIB_PATH_WIN}* ]]; then
# export PATH=${PATH};${LIB_PATH_WIN}
# fi
;;
*)
echo "Your makefile generator `uname -s` is not yet supported. Please, write an issue to https://code.it4i.cz/moldyn/4Neuro"
exit -1
;;
esac
#-------------------------------------------------------------------------
CXX_COMPILER="g++-8"
rm -rf build CMakeCache.txt;
cmake -G "${MAKEFILE_TYPE}" -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DWITH_TIME_PROFILING:BOOLEAN=${WITH_TIME_PROFILING} .
make VERBOSE=1 && echo "Build complete." || exit -1;
#cmake -G "${MAKEFILE_TYPE}" -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_CXX_COMPILER=g++-8 .
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} .
make VERBOSE=1 -j ${N_CORES} && echo "Build complete." || exit -1;
#make install;
//
// Created by martin on 8/8/18.
//
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment