summaryrefslogtreecommitdiff
path: root/eclass/cmake-utils.eclass
diff options
context:
space:
mode:
authorJohannes Huber <johu@gentoo.org>2016-12-23 10:01:40 +0100
committerJohannes Huber <johu@gentoo.org>2016-12-23 10:01:40 +0100
commited52c23f305de6b6e307be23659649ddc95ec996 (patch)
treeef66618a393c0ba718a0c233edeb69459cef1c91 /eclass/cmake-utils.eclass
parentf47cead7806797254deefe3e60eccd63745f43d6 (diff)
downloadkde-ed52c23f305de6b6e307be23659649ddc95ec996.tar.gz
kde-ed52c23f305de6b6e307be23659649ddc95ec996.tar.bz2
kde-ed52c23f305de6b6e307be23659649ddc95ec996.zip
cmake-utils.eclass: Sync with gentoo main tree
Diffstat (limited to 'eclass/cmake-utils.eclass')
-rw-r--r--eclass/cmake-utils.eclass40
1 files changed, 33 insertions, 7 deletions
diff --git a/eclass/cmake-utils.eclass b/eclass/cmake-utils.eclass
index 393ee28a26a..1fddae1ace8 100644
--- a/eclass/cmake-utils.eclass
+++ b/eclass/cmake-utils.eclass
@@ -517,22 +517,33 @@ enable_cmake-utils_src_configure() {
includes="<INCLUDES>"
fi
cat > "${build_rules}" <<- _EOF_ || die
- SET (CMAKE_AR $(type -P $(tc-getAR)) CACHE FILEPATH "Archive manager" FORCE)
- SET (CMAKE_ASM_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${includes} ${CFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "ASM compile command" FORCE)
+ SET (CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> <DEFINES> ${includes} ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "ASM compile command" FORCE)
SET (CMAKE_C_COMPILE_OBJECT "<CMAKE_C_COMPILER> <DEFINES> ${includes} ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C compile command" FORCE)
SET (CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> <DEFINES> ${includes} ${CPPFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "C++ compile command" FORCE)
SET (CMAKE_Fortran_COMPILE_OBJECT "<CMAKE_Fortran_COMPILER> <DEFINES> ${includes} ${FCFLAGS} <FLAGS> -o <OBJECT> -c <SOURCE>" CACHE STRING "Fortran compile command" FORCE)
- SET (CMAKE_RANLIB $(type -P $(tc-getRANLIB)) CACHE FILEPATH "Archive index generator" FORCE)
- SET (PKG_CONFIG_EXECUTABLE $(type -P $(tc-getPKG_CONFIG)) CACHE FILEPATH "pkg-config executable" FORCE)
_EOF_
+ local myCC=$(tc-getCC) myCXX=$(tc-getCXX) myFC=$(tc-getFC)
+
+ # !!! IMPORTANT NOTE !!!
+ # Single slash below is intentional. CMake is weird and wants the
+ # CMAKE_*_VARIABLES split into two elements: the first one with
+ # compiler path, and the second one with all command-line options,
+ # space separated.
local toolchain_file=${BUILD_DIR}/gentoo_toolchain.cmake
cat > ${toolchain_file} <<- _EOF_ || die
- SET (CMAKE_C_COMPILER $(tc-getCC))
- SET (CMAKE_CXX_COMPILER $(tc-getCXX))
- SET (CMAKE_Fortran_COMPILER $(tc-getFC))
+ SET (CMAKE_ASM_COMPILER "${myCC/ /;}")
+ SET (CMAKE_C_COMPILER "${myCC/ /;}")
+ SET (CMAKE_CXX_COMPILER "${myCXX/ /;}")
+ SET (CMAKE_Fortran_COMPILER "${myFC/ /;}")
+ SET (CMAKE_AR $(type -P $(tc-getAR)) CACHE FILEPATH "Archive manager" FORCE)
+ SET (CMAKE_RANLIB $(type -P $(tc-getRANLIB)) CACHE FILEPATH "Archive index generator" FORCE)
_EOF_
+ # We are using the C compiler for assembly by default.
+ local -x ASMFLAGS=${CFLAGS}
+ local -x PKG_CONFIG=$(tc-getPKG_CONFIG)
+
if tc-is-cross-compiler; then
local sysname
case "${KERNEL:-linux}" in
@@ -593,11 +604,26 @@ enable_cmake-utils_src_configure() {
local common_config=${BUILD_DIR}/gentoo_common_config.cmake
local libdir=$(get_libdir)
cat > "${common_config}" <<- _EOF_ || die
+ SET (CMAKE_GENTOO_BUILD ON CACHE BOOL "Indicate Gentoo package build")
SET (LIB_SUFFIX ${libdir/lib} CACHE STRING "library path suffix" FORCE)
SET (CMAKE_INSTALL_LIBDIR ${libdir} CACHE PATH "Output directory for libraries")
_EOF_
[[ "${NOCOLOR}" = true || "${NOCOLOR}" = yes ]] && echo 'SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> "${common_config}"
+ # Wipe the default optimization flags out of CMake
+ if [[ ${CMAKE_BUILD_TYPE} != Gentoo ]] && ! has "${EAPI}" 2 3 4 5; then
+ cat >> ${common_config} <<- _EOF_ || die
+ SET (CMAKE_ASM_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
+ SET (CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
+ SET (CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
+ SET (CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
+ SET (CMAKE_EXE_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
+ SET (CMAKE_MODULE_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
+ SET (CMAKE_SHARED_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
+ SET (CMAKE_STATIC_LINKER_FLAGS_${CMAKE_BUILD_TYPE^^} "" CACHE STRING "")
+ _EOF_
+ fi
+
# Convert mycmakeargs to an array, for backwards compatibility
# Make the array a local variable since <=portage-2.1.6.x does not
# support global arrays (see bug #297255).