Skip to content

Commit e6c8f31

Browse files
committed
Fix: C++ linking for MacOS.
1 parent 97810e5 commit e6c8f31

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/fpm_targets.f90

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module fpm_targets
2727
use iso_fortran_env, only: int64
2828
use fpm_error, only: error_t, fatal_error, fpm_stop
2929
use fpm_model
30-
use fpm_environment, only: get_os_type, OS_WINDOWS
30+
use fpm_environment, only: get_os_type, OS_WINDOWS, OS_MACOS
3131
use fpm_filesystem, only: dirname, join_path, canon_path
3232
use fpm_strings, only: string_t, operator(.in.), string_cat, fnv_1a, resize
3333
use fpm_compiler, only: get_macros
@@ -255,7 +255,13 @@ subroutine build_target_list(targets,model)
255255

256256
!> Add stdc++ as a linker flag. If not already there.
257257
if (.not. ("stdc++" .in. model%link_libraries)) then
258-
model%link_libraries = [model%link_libraries, string_t("stdc++")]
258+
259+
if (get_os_type() == OS_MACOS) then
260+
model%link_libraries = [model%link_libraries, string_t("c++")]
261+
else
262+
model%link_libraries = [model%link_libraries, string_t("stdc++")]
263+
end if
264+
259265
end if
260266

261267
case (FPM_UNIT_PROGRAM)

0 commit comments

Comments
 (0)