diff --git a/modules/codelite/codelite_project.lua b/modules/codelite/codelite_project.lua index 4396f0c04b..c0d95e758f 100755 --- a/modules/codelite/codelite_project.lua +++ b/modules/codelite/codelite_project.lua @@ -195,7 +195,7 @@ end local toolset = m.getcompiler(cfg) - local sysincludedirs = toolset.getincludedirs(cfg, {}, cfg.sysincludedirs) + local sysincludedirs = toolset.getincludedirs(cfg, {}, cfg.sysincludedirs, cfg.frameworkdirs) local forceincludes = toolset.getforceincludes(cfg) local cxxflags = table.concat(table.join(sysincludedirs, toolset.getcxxflags(cfg), forceincludes, cfg.buildoptions), ";") local cflags = table.concat(table.join(sysincludedirs, toolset.getcflags(cfg), forceincludes, cfg.buildoptions), ";") @@ -225,7 +225,7 @@ end local toolset = m.getcompiler(cfg) - local flags = table.join(toolset.getldflags(cfg), cfg.linkoptions, toolset.getlinks(cfg)) + local flags = table.join(toolset.getldflags(cfg), toolset.getincludedirs(cfg, {}, nil, cfg.frameworkdirs), toolset.getrunpathdirs(cfg, table.join(cfg.runpathdirs, config.getsiblingtargetdirs(cfg))), cfg.linkoptions, toolset.getlinks(cfg)) _x(3, '', table.concat(flags, ";")) diff --git a/modules/gmake/gmake_cpp.lua b/modules/gmake/gmake_cpp.lua index e1e561ef66..5fa7d1687c 100644 --- a/modules/gmake/gmake_cpp.lua +++ b/modules/gmake/gmake_cpp.lua @@ -521,7 +521,7 @@ end function make.includes(cfg, toolset) - local includes = toolset.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs) + local includes = toolset.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs, cfg.frameworkdirs) _p(' INCLUDES +=%s', make.list(includes)) end diff --git a/modules/gmake2/gmake2_cpp.lua b/modules/gmake2/gmake2_cpp.lua index bc45cbd24e..d9d4a2c4fc 100644 --- a/modules/gmake2/gmake2_cpp.lua +++ b/modules/gmake2/gmake2_cpp.lua @@ -386,7 +386,7 @@ function cpp.includes(cfg, toolset) - local includes = toolset.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs) + local includes = toolset.getincludedirs(cfg, cfg.includedirs, cfg.sysincludedirs, cfg.frameworkdirs) p.outln('INCLUDES +=' .. gmake2.list(includes)) end @@ -531,8 +531,8 @@ end end - if fcfg.includedirs or fcfg.sysincludedirs then - local includes = toolset.getincludedirs(cfg, fcfg.includedirs, fcfg.sysincludedirs) + if fcfg.includedirs or fcfg.sysincludedirs or fcfg.frameworkdirs then + local includes = toolset.getincludedirs(cfg, fcfg.includedirs, fcfg.sysincludedirs, fcfg.frameworkdirs) if #includes > 0 then value = value .. gmake2.list(includes) end diff --git a/src/tools/clang.lua b/src/tools/clang.lua index 1da61dfbb0..4eede91d48 100644 --- a/src/tools/clang.lua +++ b/src/tools/clang.lua @@ -186,10 +186,10 @@ -- An array of symbols with the appropriate flag decorations. -- - function clang.getincludedirs(cfg, dirs, sysdirs) + function clang.getincludedirs(cfg, dirs, sysdirs, frameworkdirs) -- Just pass through to GCC for now - local flags = gcc.getincludedirs(cfg, dirs, sysdirs) + local flags = gcc.getincludedirs(cfg, dirs, sysdirs, frameworkdirs) return flags end diff --git a/src/tools/gcc.lua b/src/tools/gcc.lua index d7942747bb..d6bcd71fbc 100644 --- a/src/tools/gcc.lua +++ b/src/tools/gcc.lua @@ -284,12 +284,20 @@ -- Decorate include file search paths for the GCC command line. -- - function gcc.getincludedirs(cfg, dirs, sysdirs) + function gcc.getincludedirs(cfg, dirs, sysdirs, frameworkdirs) local result = {} for _, dir in ipairs(dirs) do dir = project.getrelative(cfg.project, dir) table.insert(result, '-I' .. p.quoted(dir)) end + + if table.contains(os.getSystemTags(cfg.system), "darwin") then + for _, dir in ipairs(frameworkdirs or {}) do + dir = project.getrelative(cfg.project, dir) + table.insert(result, '-F' .. p.quoted(dir)) + end + end + for _, dir in ipairs(sysdirs or {}) do dir = project.getrelative(cfg.project, dir) table.insert(result, '-isystem ' .. p.quoted(dir)) @@ -481,6 +489,13 @@ table.insert(flags, '-L' .. p.quoted(dir)) end + if table.contains(os.getSystemTags(cfg.system), "darwin") then + for _, dir in ipairs(cfg.frameworkdirs) do + dir = project.getrelative(cfg.project, dir) + table.insert(flags, '-F' .. p.quoted(dir)) + end + end + if cfg.flags.RelativeLinks then for _, dir in ipairs(config.getlinks(cfg, "siblings", "directory")) do local libFlag = "-L" .. p.project.getrelative(cfg.project, dir) diff --git a/src/tools/msc.lua b/src/tools/msc.lua index c4d5fddfd2..9a4c37ca11 100644 --- a/src/tools/msc.lua +++ b/src/tools/msc.lua @@ -231,7 +231,7 @@ -- Decorate include file search paths for the MSVC command line. -- - function msc.getincludedirs(cfg, dirs, sysdirs) + function msc.getincludedirs(cfg, dirs, sysdirs, frameworkdirs) local result = {} dirs = table.join(dirs, sysdirs) for _, dir in ipairs(dirs) do diff --git a/tests/tools/test_gcc.lua b/tests/tools/test_gcc.lua index 4a81c42dae..faf2e9a9dd 100644 --- a/tests/tools/test_gcc.lua +++ b/tests/tools/test_gcc.lua @@ -674,6 +674,54 @@ test.contains("-L/usr/local/lib", gcc.getLibraryDirectories(cfg)) end +-- +-- Check handling of Apple frameworks search paths +-- + function suite.includeDirs_notDarwin_onFrameworkDirs() + system "Linux" + frameworkdirs { "/Library/Frameworks" } + prepare() + test.excludes("-F/Library/Frameworks", gcc.getincludedirs(cfg, {}, {}, cfg.frameworkdirs)) + end + + function suite.libDirs_notDarwin_onFrameworkDirs() + system "Windows" + frameworkdirs { "/Library/Frameworks" } + prepare() + test.excludes("-F/Library/Frameworks", gcc.getLibraryDirectories(cfg)) + end + + function suite.includeDirs_macosx_onFrameworkDirs() + system "MacOSX" + location "subdir" + frameworkdirs { + "/Library/Frameworks", + "subdir/Relative/Frameworks" + } + prepare() + test.contains("-F/Library/Frameworks", gcc.getincludedirs(cfg, {}, {}, cfg.frameworkdirs)) + test.contains("-FRelative/Frameworks", gcc.getincludedirs(cfg, {}, {}, cfg.frameworkdirs)) + end + + function suite.libDirs_macosx_onFrameworkDirs() + system "MacOSX" + location "subdir" + frameworkdirs { + "/Library/Frameworks", + "subdir/Relative/Frameworks" + } + prepare() + test.contains("-F/Library/Frameworks", gcc.getLibraryDirectories(cfg)) + test.contains("-FRelative/Frameworks", gcc.getLibraryDirectories(cfg)) + end + + function suite.includeDirs_ios_onFrameworkDirs() + system "iOS" + frameworkdirs { "/Library/Frameworks" } + prepare() + test.contains("-F/Library/Frameworks", gcc.getincludedirs(cfg, {}, {}, cfg.frameworkdirs)) + end + -- -- Check handling of link time optimization flag.