Newer
Older
cmake_minimum_required(VERSION 3.0)
message ("Before enable language")
message ("cmake for " ${CMAKE_Fortran_COMPILER})
set (CMAKE_FORTRAN_COMPILER ${CMAKE_Fortran_COMPILER})
project(4Neuro FORTRAN)
else ()
project(4Neuro)
message ("Start cmakeList")
#-------------------------------#
# Default installation location #
#-------------------------------#
# Linux: /usr/local
#------------#
# Build type #
#------------#
# Default: Release
# Others: None, Debug
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE RELEASE CACHE STRING
"Choose the type of build, options are: None Debug Release."
FORCE)
endif (NOT CMAKE_BUILD_TYPE)
#--------------------------------#
# Setting Fortran compiler flags #
#--------------------------------#
# TODO overit, jak rychle jede kod s funroll-loops
# funroll-all-loops a bez prepinace
set(standard "-std=f2008")
#--------------------#
# Automatic settings #
#--------------------#
get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
if (WITH_TIME_PROFILING)
add_definitions(-DTIME_PROFILING)
endif()
if (WIN32)
set (CMAKE_C_COMPILER gcc)
set (CMAKE_CXX_COMPILER g++)
endif()
Martin Beseda
committed
# Write compiler variables to the file - to pass them to test script
file(WRITE compilers.env "export FC=${CMAKE_Fortran_COMPILER}\n")
file(APPEND compilers.env "export CXX=${CMAKE_CXX_COMPILER}\n")
file(APPEND compilers.env "export CC=${CMAKE_C_COMPILER}\n")
# Fortran compiler detection
message ("Fortran compiler name: " ${Fortran_COMPILER_NAME})
message ("CMAKE_Fortran_COMPILER full path: " ${CMAKE_Fortran_COMPILER})
message ("Fortran compiler: " ${Fortran_COMPILER_NAME})
message ("Build type:" ${CMAKE_BUILD_TYPE})
if (Fortran_COMPILER_NAME MATCHES "gfortran.*")
# gfortran
set (CMAKE_Fortran_FLAGS_RELEASE "-funroll-loops -fno-f2c -O3 ${standard} -cpp")
Martin Beseda
committed
set (CMAKE_Fortran_FLAGS_DEBUG "-fno-f2c -O0 -g ${standard} -cpp -fimplicit-none -Wall -pedantic -fcheck=all -fbacktrace")
elseif (Fortran_COMPILER_NAME MATCHES "f95")
set (CMAKE_Fortran_FLAGS_RELEASE "-funroll-loops -fno-f2c -O3 ${standard} -cpp")
Martin Beseda
committed
set (CMAKE_Fortran_FLAGS_DEBUG "-fno-f2c -O0 -g ${standard} -cpp -fimplicit-none -Wall -pedantic -fcheck=all -fbacktrace")
elseif (Fortran_COMPILER_NAME MATCHES "ifort.*")
# ifort (untested)
set (CMAKE_Fortran_FLAGS_RELEASE "-f77rtl -O3 ${standard} -cpp")
Martin Beseda
committed
set (CMAKE_Fortran_FLAGS_DEBUG "-f77rtl -O0 -g ${standard} -cpp -fimplicit-none -Wall -pedantic -fcheck=all -fbacktrace")
elseif (Fortran_COMPILER_NAME MATCHES "g77")
# g77
set (CMAKE_Fortran_FLAGS_RELEASE "-funroll-loops -fno-f2c -O3 -m32 ${standard} -cpp")
Martin Beseda
committed
set (CMAKE_Fortran_FLAGS_DEBUG "-fno-f2c -O0 -g -m32 ${standard} -cpp -fimplicit-none -Wall -pedantic -fcheck=all -fbacktrace")
else (Fortran_COMPILER_NAME MATCHES "gfortran.*")
message ("No optimized Fortran compiler flags are known, we just try -O2 and we DO NOT support directives preprocessing (i.e. all conditional blocks will be compiled)...")
set (CMAKE_Fortran_FLAGS_RELEASE "-O2 ${standard}")
Martin Beseda
committed
set (CMAKE_Fortran_FLAGS_DEBUG "-O0 -g ${standard} -Wall -pedantic -fcheck=all")
endif (Fortran_COMPILER_NAME MATCHES "gfortran.*")
#----------------#
# User variables #
#----------------#
set(SRC_DIR src)
set(BUILD_DIR build)
set(LIB_DIR lib)
#--------------------#
# Building libraries #
#--------------------#
Martin Beseda
committed
#link_directories("${BUILD_DIR}/${LIB_DIR}")
include_directories("${BUILD_DIR}/${LIB_DIR}")
add_subdirectory("${SRC_DIR}" "${LIB_DIR}")
Martin Beseda
committed
message ("Current directory:" ${PWD})
message ("SRC_DIR: " ${SRC_DIR})
message ("BUILD_DIR:" ${BUILD_DIR})
message ("LIB_DIR: " ${LIB_DIR})
add_executable(connection_m_mem_leak_test ${SRC_DIR}/connection_m_mem_leak_test.f90)
target_link_libraries(connection_m_mem_leak_test connection_m)
message ("Windows")
else ()
add_executable(connection_m_mem_leak_test.out ${SRC_DIR}/connection_m_mem_leak_test.f90)
target_link_libraries(connection_m_mem_leak_test.out connection_m)
message ("Not Windows")
endif ()