Commit e16b282d authored by Martin Beseda's avatar Martin Beseda

FIX: Fixed installation on Windows

parent 019d55fe
cmake_minimum_required(VERSION 3.0)
project(lib4neuro)
#-------------------------------#
# Default installation location #
#-------------------------------#
# Linux: /usr/local
# Windows: c:/Program Files
#------------#
# 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 C++ compiler flags #
#--------------------------------#
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -mtune=native" )
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xHost" )
endif()
#--------------------#
# Automatic settings #
#--------------------#
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
#-------------------------#
# Find external libraries #
#-------------------------#
message("Looking for external libraries...")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
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(exprtk)
#------------------------------------------#
# Detect maximum available number of cores #
# and set corresponding build options #
#------------------------------------------#
message("Detecting available cores count...")
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()
#---------------#
# Set variables #
#---------------#
set(SRC_DIR src)
set(PROJECT_BINARY_DIR build)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY lib)
include_directories(include ${SRC_DIR})
add_subdirectory(${SRC_DIR} ${PROJECT_BINARY_DIR})
message ("Current directory:" ${CMAKE_CURRENT_SOURCE_DIR})
message ("SRC_DIR: " ${SRC_DIR})
cmake_minimum_required(VERSION 3.0)
project(lib4neuro)
#cmake_policy(SET CMP0074 NEW)
#cmake_policy(SET CMP0060 NEW)
#if(WIN32)
# message("Setting no library prefixes...")
# set(CMAKE_STATIC_LIBRARY_PREFIX "")
# set(CMAKE_SHARED_LIBRARY_PREFIX "")
# set(CMAKE_SHARED_MODULE_PREFIX "")
# set(CMAKE_IMPORT_LIBRARY_PREFIX "")
# set(PREFIX "")
# set(IMPORT_PREFIX "")
#endif()
#-------------------------------#
# Default installation location #
#-------------------------------#
# Linux: /usr/local
# Windows: c:/Program Files
#------------#
# 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 C++ compiler flags #
#--------------------------------#
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -mtune=native" )
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -xHost" )
endif()
#--------------------#
# Automatic settings #
#--------------------#
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
set(CMAKE_VERBOSE_MAKEFILE ON)
endif()
#-------------------------#
# Find external libraries #
#-------------------------#
message("Looking for external libraries...")
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(Boost_USE_MULTITHREADED ON)
find_package(Boost REQUIRED COMPONENTS serialization random)
if(Boost_FOUND)
message("Boost INCLUDE DIR: ${Boost_INCLUDEDIR}")
message("Boost LIB DIR: ${Boost_LIBRARY_DIRS}")
include_directories(${Boost_INCLUDE_DIR} ${Boost_INCLUDEDIR} ${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIRS})
endif()
find_package(exprtk)
#------------------------------------------#
# Detect maximum available number of cores #
# and set corresponding build options #
#------------------------------------------#
message("Detecting available cores count...")
include(ProcessorCount)
ProcessorCount(n_cores)
if(n_cores GREATER 1)
math(EXPR n_cores "${n_cores}-1")
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()
#---------------#
# Set variables #
#---------------#
set(SRC_DIR src)
set(PROJECT_BINARY_DIR build)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY lib)
include_directories(include ${SRC_DIR})
add_subdirectory(${SRC_DIR} ${PROJECT_BINARY_DIR})
This diff is collapsed.
################################################################################
#
# CMake script for finding ExprTk.
# The default CMake search process is used to locate files.
#
# This script creates the following variables:
# EXPRTK_FOUND: Boolean that indicates if the package was found
# EXPRTK_INCLUDE_DIRS: Paths to the necessary header files
#
################################################################################
# Find headers and libraries
FIND_PATH(
EXPRTK_INCLUDE_DIR
NAMES
exprtk.hpp
HINTS
$ENV{EXPRTK_ROOT}
${EXPRTK_ROOT}
PATHS
/usr/local
/usr
/opt/local
PATH_SUFFIXES
include
)
# Set EXPRTK_FOUND honoring the QUIET and REQUIRED arguments
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
ExprTk
"ExprTk was NOT found!"
EXPRTK_INCLUDE_DIR)
# Output variables
IF(EXPRTK_FOUND)
# Include dirs
SET(EXPRTK_INCLUDE_DIRS ${EXPRTK_INCLUDE_DIR})
ELSE()
MESSAGE(FATAL_ERROR "Set, please, the variable EXPRTK_INCLUDE_DIR to the folder, where 'exprtk.hpp' is located..")
ENDIF(EXPRTK_FOUND)
# Advanced options for not cluttering the cmake UIs:
MARK_AS_ADVANCED(EXPRTK_INCLUDE_DIR)
################################################################################
#
# CMake script for finding ExprTk.
# The default CMake search process is used to locate files.
#
# This script creates the following variables:
# EXPRTK_FOUND: Boolean that indicates if the package was found
# EXPRTK_INCLUDE_DIRS: Paths to the necessary header files
#
################################################################################
# Find headers and libraries
FIND_PATH(
EXPRTK_INCLUDE_DIR
NAMES
exprtk.hpp
HINTS
$ENV{EXPRTK_INCLUDE_DIR}
$ENV{EXPRTK_ROOT}
${EXPRTK_ROOT}
PATHS
/usr/local
/usr
/opt/local
PATH_SUFFIXES
include
)
# Set EXPRTK_FOUND honoring the QUIET and REQUIRED arguments
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
ExprTk
"ExprTk was NOT found!"
EXPRTK_INCLUDE_DIR)
# Output variables
IF(EXPRTK_FOUND)
# Include dirs
SET(EXPRTK_INCLUDE_DIRS ${EXPRTK_INCLUDE_DIR})
ELSE()
MESSAGE(FATAL_ERROR "Set, please, the variable EXPRTK_INCLUDE_DIR to the folder, where 'exprtk.hpp' is located..")
ENDIF(EXPRTK_FOUND)
# Advanced options for not cluttering the cmake UIs:
MARK_AS_ADVANCED(EXPRTK_INCLUDE_DIR)
include_directories(${EXPRTK_INCLUDE_DIRS})
@echo off
title Build lib4neuro project
rem Build type (Release/Debug)
set BUILD_TYPE=Debug
rem C++ compiler
set CXX_COMPILER=g++
rem Makefile generator
rem For the complete list type "cmake --help"
rem Example: "MSYS Makefiles", "MinGW Makefiles", "NMake Makefiles"
set MAKEFILE_GENERATOR="MSYS Makefiles"
call clean.bat
cmake -G "MSYS Makefiles" -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCMAKE_CXX_COMPILER=%CXX_COMPILER% -DBOOST_ROOT=%BOOST_ROOT% -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% -DBoost_DEBUG:BOOL=ON .
cmake --build . --config %BUILD_TYPE% -- -j %N_CORES% && (echo Build complete.) || (echo "Build finished with errors!")
@echo off
title Build lib4neuro project
rem Build type (Release/Debug)
set BUILD_TYPE=Debug
rem C++ compiler
set CXX_COMPILER=cl
set C_COMPILER=cl
rem Makefile generator
rem For the complete list type "cmake --help"
rem Example: "MSYS Makefiles", "MinGW Makefiles", "NMake Makefiles"
set MAKEFILE_GENERATOR="Visual Studio 15 2017"
call clean.bat
cmake -G %MAKEFILE_GENERATOR% -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON -DCMAKE_BUILD_TYPE=%BUILD_TYPE% -DCMAKE_CXX_COMPILER=%CXX_COMPILER% -DCMAKE_C_COMPILER=%C_COMPILER% -DBOOST_ROOT=%BOOST_ROOT% -DBOOST_LIBRARYDIR=%BOOST_LIBRARYDIR% -DBOOST_INCLUDEDIR=%BOOST_INCLUDEDIR% -DBoost_DEBUG:BOOL=ON .
cmake --build . --config %BUILD_TYPE% && (echo Build complete.) || (echo "Build finished with errors!")
@echo off
title Clean lib4neuro project
rmdir /s /q build 2>NUL
del Makefile 2>NUL
del /s /q "docs/*" 2>NUL
del "src/*TestRunner*" 2>NUL
del "src/*.o src/*.mod" 2>NUL
del src/funit.tmp 2>NUL
del "src/*_fun.f90" 2>NUL
del CMakeCache.txt 2>NUL
del cmake_install.cmake 2>NUL
del src/cmake_install.cmake 2>NUL
del /s /q CMakeFiles 2>NUL
rmdir /s /q CMakeFiles 2>NUL
rmdir /s /q src/CMakeFiles 2>NUL
rmdir /s /q src/examples/CMakeFiles 2>NUL
@echo off
title Clean lib4neuro project
rmdir /s /q build 2>NUL
del Makefile 2>NUL
del /s /q "docs/*" 2>NUL
del "src/*TestRunner*" 2>NUL
del "src/*.o src/*.mod" 2>NUL
del src/funit.tmp 2>NUL
del "src/*_fun.f90" 2>NUL
del CMakeCache.txt 2>NUL
del cmake_install.cmake 2>NUL
del src/cmake_install.cmake 2>NUL
del /s /q CMakeFiles 2>NUL
del "*.vcxproj" 2>NUL
del "*.vcxproj.filters" 2>NUL
del "*.sln" 2>NUL
rmdir /s /q CMakeFiles 2>NUL
rmdir /s /q src/CMakeFiles 2>NUL
rmdir /s /q src/examples/CMakeFiles 2>NUL
rmdir /s /q src/tests/CMakeFiles 2>NUL
\ No newline at end of file
#add_subdirectory(tests bin/unit-tests)
add_subdirectory(examples bin/examples)
add_library(4neuro SHARED
Neuron/Neuron.cpp
Neuron/NeuronBinary.cpp
Neuron/NeuronConstant.cpp
Neuron/NeuronLinear.cpp
Neuron/NeuronLogistic.cpp
Network/NeuralNetwork.cpp
Network/NeuralNetworkSum.cpp
NetConnection/ConnectionFunctionGeneral.cpp
NetConnection/ConnectionFunctionIdentity.cpp
LearningMethods/ParticleSwarm.cpp
DataSet/DataSet.cpp
ErrorFunction/ErrorFunctions.cpp
Solvers/DESolver.cpp
LearningMethods/ILearningMethods.h)
target_link_libraries(4neuro boost_serialization)
add_library(boost_unit_test SHARED boost_test_lib_dummy.cpp)
add_library(exprtk SHARED exprtk.cpp)
#TODO uncomment
#add_subdirectory(tests bin/unit-tests)
add_subdirectory(examples bin/examples)
add_library(4neuro SHARED
Neuron/Neuron.cpp
Neuron/NeuronBinary.cpp
Neuron/NeuronConstant.cpp
Neuron/NeuronLinear.cpp
Neuron/NeuronLogistic.cpp
Network/NeuralNetwork.cpp
Network/NeuralNetworkSum.cpp
NetConnection/ConnectionFunctionGeneral.cpp
NetConnection/ConnectionFunctionIdentity.cpp
LearningMethods/ParticleSwarm.cpp
DataSet/DataSet.cpp
ErrorFunction/ErrorFunctions.cpp
Solvers/DESolver.cpp
LearningMethods/ILearningMethods.h)
#list(REMOVE_ITEM Boost_LIBRARIES "optimized" "debug")
#
#set(TMP "")
#set(TMP2 "")
#foreach(e ${Boost_LIBRARIES})
# string(REPLACE "/" "\\" TMP2 ${e})
# list(APPEND TMP ${TMP2})
#endforeach(e)
#
#set(Boost_LIBRARIES ${TMP})
message("Boost_LIBRARIES sadf: ${Boost_LIBRARIES}")
target_link_libraries(4neuro ${Boost_LIBRARIES})
add_library(boost_unit_test SHARED boost_test_lib_dummy.cpp)
add_library(exprtk SHARED exprtk.cpp)
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