Skip to content
Snippets Groups Projects
Commit a8ff3856 authored by Wuttke, Joachim's avatar Wuttke, Joachim
Browse files

[j.2] CMake cleanup: rm variable BA_PLATFORM, sort sections, require 64-bit platform. ()

Merging branch 'j.2'  into 'main'.

See merge request !2504
parents 916a6303 49703fd7
No related branches found
No related tags found
1 merge request!2504CMake cleanup: rm variable BA_PLATFORM, sort sections, require 64-bit platform.
Pipeline #139227 passed
...@@ -21,7 +21,7 @@ include(cmake/commons/PreventInSourceBuilds) ...@@ -21,7 +21,7 @@ include(cmake/commons/PreventInSourceBuilds)
### Project settings ### Project settings
project(BornAgain project(BornAgain
VERSION 22.0 VERSION 22.0 # will always remain binary; minor equals patch-level
DESCRIPTION "BornAgain: simulate and fit reflectometry and grazing-incidence scattering." DESCRIPTION "BornAgain: simulate and fit reflectometry and grazing-incidence scattering."
HOMEPAGE_URL https://www.bornagainproject.org HOMEPAGE_URL https://www.bornagainproject.org
LANGUAGES CXX) LANGUAGES CXX)
...@@ -123,10 +123,17 @@ if(BA_TESTS) ...@@ -123,10 +123,17 @@ if(BA_TESTS)
# => 'make check' is an alias for 'ctest' # => 'make check' is an alias for 'ctest'
add_custom_target(fullcheck COMMAND ${CMAKE_CTEST_COMMAND}) add_custom_target(fullcheck COMMAND ${CMAKE_CTEST_COMMAND})
# => 'make check' is an alias for 'ctest' # => 'make check' is an alias for 'ctest'
endif() endif()
### Operating system and compilation flags
### Operating system # no support for systems with addresses shorter than 64 bits
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
message(FATAL "Found a 32bit system - no longer supported")
elseif(CMAKE_SIZEOF_VOID_P LESS 8)
message(FATAL "Found a ${CMAKE_SIZEOF_VOID_P} byte system - very unexpected and not supported")
endif()
# introduce `LINUX` flag (whereas `APPLE` and `WIN32` are set by CMake) # introduce `LINUX` flag (whereas `APPLE` and `WIN32` are set by CMake)
if(UNIX AND CMAKE_SYSTEM_NAME MATCHES Linux) if(UNIX AND CMAKE_SYSTEM_NAME MATCHES Linux)
...@@ -138,34 +145,6 @@ if(NOT (LINUX OR APPLE OR WIN32)) ...@@ -138,34 +145,6 @@ if(NOT (LINUX OR APPLE OR WIN32))
message(FATAL_ERROR "Operating system ${CMAKE_SYSTEM_NAME} is not supported") message(FATAL_ERROR "Operating system ${CMAKE_SYSTEM_NAME} is not supported")
endif() endif()
### Further configuration
# function definitions
include(cmake/commons/GetFilenameComponent) # fct get_filename_component (overwrites CMake's built-in)
if(BORNAGAIN_PYTHON)
include(cmake/multipython/SwigLib) # fct SwigLib
endif()
include(cmake/BornAgain/MakeLib) # fct MakeLib
# main settings
include(cmake/BornAgain/Directories)
include(cmake/BornAgain/FindLibraries)
if(WIN32)
include(cmake/BornAgain/InstallDll)
endif()
# Python
if(BORNAGAIN_PYTHON)
include(cmake/multipython/PyDependences)
endif()
if(BA_GUI)
include(cmake/BornAgain/Qt)
string(APPEND CMAKE_CXX_FLAGS " -DHAVE_QT=ON")
endif()
if(LINUX) if(LINUX)
include(cmake/BornAgain/Linux) include(cmake/BornAgain/Linux)
elseif(APPLE) elseif(APPLE)
...@@ -174,7 +153,6 @@ elseif(WIN32) ...@@ -174,7 +153,6 @@ elseif(WIN32)
include(cmake/BornAgain/Windows) include(cmake/BornAgain/Windows)
endif() endif()
include(cmake/BornAgain/ConfigureFiles)
include(cmake/BornAgain/CompilerInfo) include(cmake/BornAgain/CompilerInfo)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
...@@ -198,6 +176,35 @@ if(ALGORITHM_DIAGNOSTIC) ...@@ -198,6 +176,35 @@ if(ALGORITHM_DIAGNOSTIC)
endif() endif()
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -DBA_DEBUG") # changes behavior of ASSERT string(APPEND CMAKE_CXX_FLAGS_DEBUG " -DBA_DEBUG") # changes behavior of ASSERT
### Further configuration
# function definitions
include(cmake/commons/GetFilenameComponent) # fct get_filename_component (overwrites CMake's built-in)
if(BORNAGAIN_PYTHON)
include(cmake/multipython/SwigLib) # fct SwigLib
endif()
include(cmake/BornAgain/MakeLib) # fct MakeLib
# main settings
include(cmake/BornAgain/Directories)
include(cmake/BornAgain/FindLibraries)
if(WIN32)
include(cmake/BornAgain/InstallDll)
endif()
# Python
if(BORNAGAIN_PYTHON)
include(cmake/multipython/PyDependences)
endif()
if(BA_GUI)
include(cmake/BornAgain/Qt)
string(APPEND CMAKE_CXX_FLAGS " -DHAVE_QT=ON")
endif()
include(cmake/BornAgain/ConfigureFiles)
### Configure source components ### Configure source components
# library Fit # library Fit
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
## ##
## ************************************************************************************************ ## ************************************************************************************************
message(STATUS "BornAgain Platform: ${BA_PLATFORM}")
message(STATUS "BornAgain Architecture: ${BA_ARCHITECTURE}") message(STATUS "BornAgain Architecture: ${BA_ARCHITECTURE}")
message(STATUS "Default compiler flags (may be changed in later CMake steps):") message(STATUS "Default compiler flags (may be changed in later CMake steps):")
......
...@@ -12,20 +12,18 @@ ...@@ -12,20 +12,18 @@
## ##
## ************************************************************************************************ ## ************************************************************************************************
set(BA_ARCHITECTURE linux) #... Set architecture variables
set(BA_PLATFORM linux)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # generate compile_commands.json, for use with code analysis tools if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL x86_64)
set(BA_ARCHITECTURE linux_x64)
if(CMAKE_SIZEOF_VOID_P GREATER 4)
message(STATUS "Found a 64bit system")
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL x86_64)
set(BA_ARCHITECTURE linux_x64)
endif()
else() else()
message(STATUS "Found a 32bit system, not covered by our CI tests - proceed on your own risk") set(BA_ARCHITECTURE "linux_${CMAKE_SYSTEM_PROCESSOR}")
endif() endif()
#... Set compile options
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # generate compile_commands.json, used by code analysis tools
set(CMAKE_CXX_FLAGS_RELEASE "-O3") set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_CXX_FLAGS_DEBUG "-g3") set(CMAKE_CXX_FLAGS_DEBUG "-g3")
if(GCC) if(GCC)
...@@ -34,7 +32,8 @@ else() ...@@ -34,7 +32,8 @@ else()
string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0") # was longtime -O2 string(APPEND CMAKE_CXX_FLAGS_DEBUG " -O0") # was longtime -O2
endif() endif()
string(APPEND CMAKE_CXX_FLAGS " -I${CMAKE_SOURCE_DIR}/Wrap -pipe ${BIT_ENVIRONMENT} -Wall -W -Woverloaded-virtual -Wno-unknown-pragmas -fPIC") string(APPEND CMAKE_CXX_FLAGS " -I${CMAKE_SOURCE_DIR}/Wrap -pipe ${BIT_ENVIRONMENT}")
string(APPEND CMAKE_CXX_FLAGS " -Wall -W -Woverloaded-virtual -Wno-unknown-pragmas -fPIC")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
string(APPEND CMAKE_CXX_FLAGS " -Wno-restrict") # under g++ -std=c++20, warnings from <string> string(APPEND CMAKE_CXX_FLAGS " -Wno-restrict") # under g++ -std=c++20, warnings from <string>
endif() endif()
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
## ##
## ************************************************************************************************ ## ************************************************************************************************
set(BA_PLATFORM mac) #... Check OS version
if(NOT CMAKE_SYSTEM_NAME MATCHES Darwin) if(NOT CMAKE_SYSTEM_NAME MATCHES Darwin)
message(FATAL_ERROR "Found a non-Darwin system, currently unsupported") message(FATAL_ERROR "Found a non-Darwin system, currently unsupported")
...@@ -30,22 +30,16 @@ if(${MACOSX_VERSION} LESS 11) ...@@ -30,22 +30,16 @@ if(${MACOSX_VERSION} LESS 11)
message(FATAL_ERROR "Found a MacOS < 11.0, which is unsupported") message(FATAL_ERROR "Found a MacOS < 11.0, which is unsupported")
endif() endif()
#TODO: check haveconfig and rpath -> set rpath true #... Set architecture variables
#TODO: check Thread, define link command
#TODO: more stuff check configure script
execute_process(COMMAND /usr/sbin/sysctl machdep.cpu.extfeatures OUTPUT_VARIABLE SYSCTL_OUTPUT)
if(NOT ${SYSCTL_OUTPUT} MATCHES 64)
message(FATAL "Found a 32bit system - no longer supported")
endif()
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES arm) if(${CMAKE_SYSTEM_PROCESSOR} MATCHES arm)
# arch = arm64 set(BA_ARCHITECTURE "mac_arm")
set(BA_ARCHITECTURE "${BA_PLATFORM}_arm")
else() else()
# arch = x86_64 set(BA_ARCHITECTURE "mac_x64")
set(BA_ARCHITECTURE "${BA_PLATFORM}_x64")
endif() endif()
#... Set compile options
# On OS X, the `-dead_strip` flag removes unneeded symbols/object files, and # On OS X, the `-dead_strip` flag removes unneeded symbols/object files, and
# `-dead_strip_dylibs` flag removes unneeded libraries [see `man ld` on OSX] # `-dead_strip_dylibs` flag removes unneeded libraries [see `man ld` on OSX]
set(DEADSTRIP_LFLAGS "-dead_strip -dead_strip_dylibs") set(DEADSTRIP_LFLAGS "-dead_strip -dead_strip_dylibs")
...@@ -53,7 +47,6 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") ...@@ -53,7 +47,6 @@ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
string(APPEND CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS " -m64 ${DEADSTRIP_LFLAGS}") string(APPEND CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS " -m64 ${DEADSTRIP_LFLAGS}")
string(APPEND CMAKE_CXX_FLAGS " -m64 -I${CMAKE_SOURCE_DIR}/Wrap") string(APPEND CMAKE_CXX_FLAGS " -m64 -I${CMAKE_SOURCE_DIR}/Wrap")
if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCXX)
message(STATUS "Found GNU compiler collection") message(STATUS "Found GNU compiler collection")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} execute_process(COMMAND ${CMAKE_CXX_COMPILER}
......
...@@ -12,20 +12,17 @@ ...@@ -12,20 +12,17 @@
## ##
## ************************************************************************************************ ## ************************************************************************************************
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) #... Set architecture variables
set(BA_ARCHITECTURE win64)
if(${CMAKE_SIZEOF_VOID_P} EQUAL 8) #... Set compile options
set(BA_ARCHITECTURE win64)
set(BA_PLATFORM win64) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
else()
set(BA_ARCHITECTURE win32)
set(BA_PLATFORM win32)
endif()
string(APPEND CMAKE_CXX_FLAGS " /MD /MP") string(APPEND CMAKE_CXX_FLAGS " /MD /MP")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELEASE " /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrtd.lib") string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELEASE " /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:msvcrtd.lib")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG " /NODEFAULTLIB:libcmt.lib") string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG " /NODEFAULTLIB:libcmt.lib")
# --- switch ON edit and continue; only in DEBUG configuration
add_compile_options($<$<CONFIG:Debug>:/ZI>) add_compile_options($<$<CONFIG:Debug>:/ZI>)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment