tasmet/CMakeLists.txt

133 lines
4.4 KiB
CMake
Raw Normal View History

# CMakeList.txt for TaSMET
2016-12-15 20:34:11 +00:00
cmake_minimum_required (VERSION 3.6)
project(TaSMET)
set(PACKAGE_VERSION 0.1)
message("Running Cmake for TaSMET version ${PACKAGE_VERSION}")
# Set the Python version to link against. If this is not set, Cmake tries to find it automatically.
# set(TaSMET_PY_VERSION "2.7")
set(TaSMET_PY_VERSION "3.5m")
# Tracer name (name of the variable)
add_definitions(-DTRACER=1)
# add_definitions(-DTRACER_IN_COMMON)
add_definitions(-DTASMET_FLOAT=64)
2016-11-13 14:56:35 +00:00
add_definitions(-DTASMET_DEBUG=1)
#====================================================
# Compiler settings ************************************************
#====================================================
# Always required make flags in case of both compilers
2016-12-15 20:34:11 +00:00
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pipe -fPIC -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable ")
# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wfatal-errors -pipe -fPIC -Wall -Wextra -Wno-unused-parameter -Wno-unused-variable ")
#========Qt5 Stuff ==================================
find_package(Qt5Widgets)
find_package(Qt5Core)
find_package(Protobuf REQUIRED)
# Add the include directories for the Qt 5 Widgets module to
# the compile lines.
include_directories(${Qt5Widgets_INCLUDE_DIRS})
# Use the compile definitions defined in the Qt 5 Widgets module
add_definitions(${Qt5Widgets_DEFINITIONS})
# Add compiler flags for building executables (-fPIE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
#==================================================
# Optimized code flags *******************************************
#==================================================
#Debug mode
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX)FLAGS} -g -ggdb")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 -march=native -mtune=native")
# set(CMAKE_CLANG "${CMAKE_GCC} -march=native -mtune=native -fopenmp")
# To disable bound checking on std::vector, and to disable assertions
# add_definitions(-DNDEBUG)
# To increase speed on Armadillo
# add_definitions(-DARMA_NO_DEBUG)
# Disable traces
# add_definitions(-DTRACER=0)
# Pre-allocation size for matrices. Very important setting to tune the
# code in case we know that we are going to run with certain sizes of matrices and vectors. For Nf=6, set this to (2*Nf+1)^2=169
# For Nf=1: 9
# For Nf=2: 25
# For Nf=3: 49
# For Nf=4: 81
# For Nf=5: 121
# For Nf=6: 169
# For Nf=7: 225
# For Nf=8: 289
# For Nf=9: 361
# For Nf=10: 441
# For Nf=11: 529
# For Nf=12: 625
# Watch out! Setting prealloc too high can give too much overhead for smaller Nf's
# add_definitions(-DARMA_MAT_PREALLOC=625)
# ##########################
# Finding the presence of the prerequisites
# ##########################
# For importing find directives for Cmake
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake_tools)
# ##########################
# Python #####################
# ##########################
2016-12-15 20:34:11 +00:00
include_directories(/usr/include/PythonQt)
if(TaSMET_PY_VERSION)
# Find major version from version string
set(PYTHON_LIBRARY "/usr/lib/libpython${TaSMET_PY_VERSION}.so")
set(PYTHON_INCLUDE_DIR "/usr/include/python${TaSMET_PY_VERSION}")
set(PYTHON_INCLUDE_DIRS "/usr/include/python${TaSMET_PY_VERSION}")
endif(TaSMET_PY_VERSION)
message("Python include dirs: ${PYTHON_INCLUDE_DIRS}")
find_package(PythonLibs REQUIRED)
string(REGEX MATCH "^." TaSMET_PY_MAJOR_VERSION ${PYTHONLIBS_VERSION_STRING})
MESSAGE("Python major version: ${TaSMET_PY_MAJOR_VERSION}")
# Find the site_packages directory of python
execute_process(COMMAND python${TaSMET_PY_MAJOR_VERSION} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())" OUTPUT_VARIABLE PYTHON_SITE_PACKAGES OUTPUT_STRIP_TRAILING_WHITESPACE)
# Armadillo
find_package(Armadillo REQUIRED)
add_definitions(-DARMA_USE_SUPERLU -DARMA_USE_CXX11)
# ==================== Compile the code in common and src
# This is the common code (gas and solid libs, etc)
# link_directories(common)
include_directories(
${PYTHON_INCLUDE_DIRS}
src
src/solver
src/material
src/sys
)
# Add the code subdirectory
add_subdirectory(src)
add_subdirectory(testing)
2016-12-15 20:34:11 +00:00
# add_executable(tasmet src/main.cpp src/main.moc)
add_executable(tasmet src/main.cpp)
target_link_libraries(tasmet tasmet_gui tasmet_src messages PythonQt Qt5::Widgets)