diff mbox

[v2,05/15] pkg-cmake.mk: export the fortran compiler path in the CMake toolchain file

Message ID 20160701162920.19632-6-s.martin49@gmail.com
State Changes Requested
Headers show

Commit Message

Samuel Martin July 1, 2016, 4:29 p.m. UTC
Since the fortran support is conditional, only enable it when needed.

Signed-off-by: Samuel Martin <s.martin49@gmail.com>
Signed-off-by: Vicente Olivert Riera <Vincent.Riera@imgtec.com>
Cc: Benjamin Kamath <bkamath@spaceflight.com>

---
changes v1->v2:
- set CMAKE_Fortran_FLAGS in the toolchainfile.cmake (Benjamin K.)
---
 package/pkg-cmake.mk                | 3 +++
 support/misc/toolchainfile.cmake.in | 4 ++++
 2 files changed, 7 insertions(+)

Comments

Thomas Petazzoni July 1, 2016, 9:02 p.m. UTC | #1
Hello,

On Fri,  1 Jul 2016 18:29:10 +0200, Samuel Martin wrote:

> +		-e 's#@@TOOLCHAIN_HAS_FORTRAN@@#$(if $(BR2_TOOLCHAIN_HAS_FORTRAN),1,0)#' \

The BR2_TOOLCHAIN_HAS_FORTRAN variable doesn't exist at this point in
the patch series, so shouldn't this patch come later?

Or did you assume that because it doesn't exist, it's always false for
the moment, and that this patch should be considered a "preparation"
patch ?

Thanks,

Thomas
Samuel Martin July 1, 2016, 9:37 p.m. UTC | #2
On Fri, Jul 1, 2016 at 11:02 PM, Thomas Petazzoni
<thomas.petazzoni@free-electrons.com> wrote:
> Hello,
>
> On Fri,  1 Jul 2016 18:29:10 +0200, Samuel Martin wrote:
>
>> +             -e 's#@@TOOLCHAIN_HAS_FORTRAN@@#$(if $(BR2_TOOLCHAIN_HAS_FORTRAN),1,0)#' \
>
> The BR2_TOOLCHAIN_HAS_FORTRAN variable doesn't exist at this point in
> the patch series, so shouldn't this patch come later?
>
> Or did you assume that because it doesn't exist, it's always false for
> the moment, and that this patch should be considered a "preparation"
> patch ?
Nope, I just screwed my rebase :-S

>
> Thanks,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
diff mbox

Patch

diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk
index 81dcfcc..1fe2e51 100644
--- a/package/pkg-cmake.mk
+++ b/package/pkg-cmake.mk
@@ -243,9 +243,12 @@  $(HOST_DIR)/usr/share/buildroot/toolchainfile.cmake:
 		-e 's#@@STAGING_SUBDIR@@#$(call qstrip,$(STAGING_SUBDIR))#' \
 		-e 's#@@TARGET_CFLAGS@@#$(call qstrip,$(TARGET_CFLAGS))#' \
 		-e 's#@@TARGET_CXXFLAGS@@#$(call qstrip,$(TARGET_CXXFLAGS))#' \
+		-e 's#@@TARGET_FCFLAGS@@#$(call qstrip,$(TARGET_FCFLAGS))#' \
 		-e 's#@@TARGET_LDFLAGS@@#$(call qstrip,$(TARGET_LDFLAGS))#' \
 		-e 's#@@TARGET_CC@@#$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_CC)))#' \
 		-e 's#@@TARGET_CXX@@#$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_CXX)))#' \
+		-e 's#@@TARGET_FC@@#$(subst $(HOST_DIR)/,,$(call qstrip,$(TARGET_FC)))#' \
 		-e 's#@@CMAKE_SYSTEM_PROCESSOR@@#$(call qstrip,$(CMAKE_SYSTEM_PROCESSOR))#' \
+		-e 's#@@TOOLCHAIN_HAS_FORTRAN@@#$(if $(BR2_TOOLCHAIN_HAS_FORTRAN),1,0)#' \
 		$(TOPDIR)/support/misc/toolchainfile.cmake.in \
 		> $@
diff --git a/support/misc/toolchainfile.cmake.in b/support/misc/toolchainfile.cmake.in
index 5cf381e..e550b8f 100644
--- a/support/misc/toolchainfile.cmake.in
+++ b/support/misc/toolchainfile.cmake.in
@@ -29,3 +29,7 @@  set(ENV{PKG_CONFIG_SYSROOT_DIR} "${RELOCATED_HOST_DIR}/@@STAGING_SUBDIR@@")
 # This toolchain file can be used both inside and outside Buildroot.
 set(CMAKE_C_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CC@@")
 set(CMAKE_CXX_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_CXX@@")
+if(@@TOOLCHAIN_HAS_FORTRAN@@)
+  set(CMAKE_Fortran_FLAGS "@@TARGET_FCFLAGS@@ ${CMAKE_Fortran_FLAGS}" CACHE STRING "Buildroot FCFLAGS")
+  set(CMAKE_Fortran_COMPILER "${RELOCATED_HOST_DIR}/@@TARGET_FC@@")
+endif()