make-rules/cmake.mk
author Norm Jacobs <Norm.Jacobs@Oracle.COM>
Thu, 11 Feb 2016 22:32:09 -0800
changeset 5453 12788f3c6c43
parent 5125 34cc580c62c2
child 5597 bcd66d6b1f98
permissions -rw-r--r--
22302071 diffutils builds with the wrong compiler
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5125
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     1
#
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     2
# CDDL HEADER START
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     3
#
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     4
# The contents of this file are subject to the terms of the
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     5
# Common Development and Distribution License (the "License").
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     6
# You may not use this file except in compliance with the License.
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     7
#
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     8
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
     9
# or http://www.opensolaris.org/os/licensing.
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    10
# See the License for the specific language governing permissions
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    11
# and limitations under the License.
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    12
#
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    13
# When distributing Covered Code, include this CDDL HEADER in each
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    14
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    15
# If applicable, add the following below this CDDL HEADER, with the
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    16
# fields enclosed by brackets "[]" replaced with your own identifying
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    17
# information: Portions Copyright [yyyy] [name of copyright owner]
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    18
#
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    19
# CDDL HEADER END
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    20
#
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    21
# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    22
#
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    23
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    24
#
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    25
# This file sets up the default options and base requirements for GNOME
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    26
# components.
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    27
#
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    28
include $(WS_MAKE_RULES)/prep.mk
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    29
# Most cmake-based components require intltools.
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    30
include $(WS_MAKE_RULES)/intltool.mk
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    31
# cmake components don't generally use autoconf.
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    32
include $(WS_MAKE_RULES)/justmake.mk
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    33
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    34
# Ensure correct version of libraries are linked to.
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    35
LDFLAGS += "$(CC_BITS)"
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    36
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    37
# This component uses cmake to generate Makefiles and so has no configure
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    38
CMAKE = $(shell which cmake)
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    39
CMAKE_BUILD_TYPE ?= RelWithDebInfo
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    40
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    41
CMAKE_OPTIONS += -DCMAKE_CXX_COMPILER="$(CXX)"
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    42
CMAKE_OPTIONS += -DCMAKE_CXX_FLAGS="$(CXXFLAGS)"
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    43
CMAKE_OPTIONS += -DCMAKE_C_COMPILER="$(CC)"
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    44
CMAKE_OPTIONS += -DCMAKE_C_FLAGS="$(CFLAGS)"
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    45
CMAKE_OPTIONS += -DCMAKE_EXE_LINKER_FLAGS="$(LDFLAGS)"
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    46
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    47
# Must start install paths with a leading '/' or files will be installed into
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    48
# wrong location!
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    49
CMAKE_OPTIONS += -DCMAKE_INSTALL_PREFIX="$(USRDIR)"
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    50
CMAKE_OPTIONS += -DCMAKE_MODULE_LINKER_FLAGS="$(LDFLAGS)"
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    51
CMAKE_OPTIONS += -DCMAKE_SHARED_LINKER_FLAGS="$(LDFLAGS)"
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    52
CMAKE_OPTIONS += -DGETTEXT_MSGFMT_EXECUTABLE="$(GNUBIN)/msgfmt"
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    53
CMAKE_OPTIONS += -DBIN_INSTALL_DIR="$(USRBIN)"
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    54
CMAKE_OPTIONS += -DEXEC_INSTALL_DIR="$(USRBIN)"
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    55
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    56
# Some components use LIB_INSTALL_DIR, as-is, others forcibly ignore it and set
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    57
# based on CMAKE_INSTALL_PREFIX.  Those usually instead offer a LIB_SUFFIX
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    58
# variable that we can generally use to accomplish the same result.  Setting
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    59
# them both shouldn't harm anything.
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    60
CMAKE_OPTIONS += -DLIB_INSTALL_DIR="$(USRLIB)"
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    61
CMAKE_OPTIONS.64 += -DLIB_SUFFIX="/$(MACH64)"
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    62
CMAKE_OPTIONS += -DLIBEXEC_INSTALL_DIR="$(USRLIB)"
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    63
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    64
# Required to ensure expected defines are set; also, ensures project's
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    65
# optimisation level set appropriately.
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    66
CMAKE_OPTIONS += -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE)
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    67
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    68
CMAKE_OPTIONS += $(CMAKE_OPTIONS.$(BITS))
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    69
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    70
COMPONENT_PRE_BUILD_ACTION += cd $(@D);
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    71
COMPONENT_PRE_BUILD_ACTION += echo Running cmake with $(CMAKE_OPTIONS);
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    72
COMPONENT_PRE_BUILD_ACTION += $(CMAKE) . $(CMAKE_OPTIONS);
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    73
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    74
# Ensure cmake finds the matching 32/64-bit version of dependencies.
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    75
COMPONENT_BUILD_ENV += PKG_CONFIG_PATH="$(PKG_CONFIG_PATH)"
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    76
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    77
REQUIRED_PACKAGES += developer/build/cmake
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    78
REQUIRED_PACKAGES += developer/build/pkg-config
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    79
REQUIRED_PACKAGES += developer/gnu-binutils
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    80
REQUIRED_PACKAGES += developer/intltool
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    81
REQUIRED_PACKAGES += system/library
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    82
REQUIRED_PACKAGES += system/linker
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    83
# Most cmake-based components expect GNU versions of these.
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    84
REQUIRED_PACKAGES += text/gawk
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    85
REQUIRED_PACKAGES += text/gnu-grep
34cc580c62c2 21029732 PKG_CONFIG_PATH should be included in CONFIGURE_ENV and BUILD_ENV
Shawn Walker-Salas <shawn.walker@oracle.com>
parents:
diff changeset
    86
REQUIRED_PACKAGES += text/gnu-sed