comparison Resources/Orthanc/Toolchains/LinuxStandardBaseToolchain.cmake @ 36:fd58eb5749ed

CMake simplification using DownloadOrthancFramework.cmake
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 06 Jul 2020 17:37:30 +0200
parents
children 1b6af7a317bf
comparison
equal deleted inserted replaced
35:77f4e165e535 36:fd58eb5749ed
1 #
2 # Full build, as used on the BuildBot CIS:
3 #
4 # $ LSB_CC=gcc-4.8 LSB_CXX=g++-4.8 cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=../Resources/LinuxStandardBaseToolchain.cmake -DUSE_LEGACY_JSONCPP=ON -DUSE_LEGACY_LIBICU=ON -DBOOST_LOCALE_BACKEND=icu -DENABLE_PKCS11=ON -G Ninja
5 #
6 # Or, more lightweight version (without libp11 and ICU):
7 #
8 # $ LSB_CC=gcc-4.8 LSB_CXX=g++-4.8 cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=../Resources/LinuxStandardBaseToolchain.cmake -DUSE_LEGACY_JSONCPP=ON -G Ninja
9 #
10
11 INCLUDE(CMakeForceCompiler)
12
13 SET(LSB_PATH $ENV{LSB_PATH} CACHE STRING "")
14 SET(LSB_CC $ENV{LSB_CC} CACHE STRING "")
15 SET(LSB_CXX $ENV{LSB_CXX} CACHE STRING "")
16 SET(LSB_TARGET_VERSION "4.0" CACHE STRING "")
17
18 IF ("${LSB_PATH}" STREQUAL "")
19 SET(LSB_PATH "/opt/lsb")
20 ENDIF()
21
22 IF (EXISTS ${LSB_PATH}/lib64)
23 SET(LSB_TARGET_PROCESSOR "x86_64")
24 SET(LSB_LIBPATH ${LSB_PATH}/lib64-${LSB_TARGET_VERSION})
25 ELSEIF (EXISTS ${LSB_PATH}/lib)
26 SET(LSB_TARGET_PROCESSOR "x86")
27 SET(LSB_LIBPATH ${LSB_PATH}/lib-${LSB_TARGET_VERSION})
28 ELSE()
29 MESSAGE(FATAL_ERROR "Unable to detect the target processor architecture. Check the LSB_PATH environment variable.")
30 ENDIF()
31
32 SET(LSB_CPPPATH ${LSB_PATH}/include)
33 SET(PKG_CONFIG_PATH ${LSB_LIBPATH}/pkgconfig/)
34
35 # the name of the target operating system
36 SET(CMAKE_SYSTEM_NAME Linux)
37 SET(CMAKE_SYSTEM_VERSION LinuxStandardBase)
38 SET(CMAKE_SYSTEM_PROCESSOR ${LSB_TARGET_PROCESSOR})
39
40 # which compilers to use for C and C++
41 SET(CMAKE_C_COMPILER ${LSB_PATH}/bin/lsbcc)
42
43 if (${CMAKE_VERSION} VERSION_LESS "3.6.0")
44 CMAKE_FORCE_CXX_COMPILER(${LSB_PATH}/bin/lsbc++ GNU)
45 else()
46 SET(CMAKE_CXX_COMPILER ${LSB_PATH}/bin/lsbc++)
47 endif()
48
49 # here is the target environment located
50 SET(CMAKE_FIND_ROOT_PATH ${LSB_PATH})
51
52 # adjust the default behaviour of the FIND_XXX() commands:
53 # search headers and libraries in the target environment, search
54 # programs in the host environment
55 SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
56 SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER)
57 SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER)
58
59 SET(CMAKE_CROSSCOMPILING OFF)
60
61
62 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -I${LSB_PATH}/include" CACHE INTERNAL "" FORCE)
63 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -nostdinc++ -I${LSB_PATH}/include -I${LSB_PATH}/include/c++ -I${LSB_PATH}/include/c++/backward" CACHE INTERNAL "" FORCE)
64 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -L${LSB_LIBPATH} --lsb-besteffort" CACHE INTERNAL "" FORCE)
65 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --lsb-target-version=${LSB_TARGET_VERSION} -L${LSB_LIBPATH} --lsb-besteffort" CACHE INTERNAL "" FORCE)
66
67 if (NOT "${LSB_CXX}" STREQUAL "")
68 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --lsb-cxx=${LSB_CXX}")
69 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --lsb-cxx=${LSB_CXX}")
70 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --lsb-cxx=${LSB_CXX}")
71 endif()
72
73 if (NOT "${LSB_CC}" STREQUAL "")
74 SET(CMAKE_C_FLAGS "${CMAKE_CC_FLAGS} --lsb-cc=${LSB_CC}")
75 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --lsb-cc=${LSB_CC}")
76 SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --lsb-cc=${LSB_CC}")
77 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --lsb-cc=${LSB_CC}")
78 endif()
79