dyne / frei0r

A large collection of free and portable video plugins
https://frei0r.dyne.org/
GNU General Public License v2.0
420 stars 90 forks source link

build failure OS X #64

Closed rdp closed 5 years ago

rdp commented 5 years ago
 $ cmake .
-- Checking for module 'opencv'
--   No package 'opencv' found
-- WARNING: OpenCV was not found. Please specify OpenCV directory using OpenCV_DIR env. variable
-- Checking for module 'cairo'
--   No package 'cairo' found
-- Checking for module 'gavl'
--   No package 'gavl' found
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE) 
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/rdp/dev/ffmpeg-windows-build-helpers/sandbox/native/frei0r_git
frei0r_git rdp$ make
[  0%] Linking C shared module 3dflippo.so
ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)
ld: in '/usr/local/lib/libunwind.dylib', file was built for x86_64 which is not the architecture being linked (i386): /usr/local/lib/libunwind.dylib for architecture i386
clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [src/filter/3dflippo/3dflippo.so] Error 1
make[1]: *** [src/filter/3dflippo/CMakeFiles/3dflippo.dir/all] Error 2
make: *** [all] Error 2
ddennedy commented 5 years ago

I have this problem as well using CMake instead of the autotools build except in my case it is with /opt/local/lib/libcairo.dylib from MacPorts. I do not make universal/multiarch builds with MacPorts, and the CMake picks up this optional dependency. My usual workaround is to manually:

--- CMakeLists.txt
+++ CMakeLists.txt
@@ -24,8 +24,8 @@ set(CMAKE_CXX_FLAGS "-Waddress -Wtype-limits -Wsign-compare")
 if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
   set(CMAKE_C_COMPILER "clang")
   set(CMAKE_CXX_COMPILER "clang++")
-  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wrestrict -arch x86_64 -arch i386")
-  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wrestrict -arch x86_64 -arch i386")
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wrestrict")
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wrestrict")
 endif ()

But I think we should change something to make a better out-of-the-box experience. I think i386 for mac is quite rare now. My Shotcut build uses autotools, which does not automatically try to do a multi-arch build.

ddennedy commented 5 years ago

I also get warning: unknown warning option '-Wrestrict' [-Wunknown-warning-option]. So, why not simply remove these lines (this whole if block?) and let users override/set things as-needed using cmake properties?

Lastly, according to CMake docs, CFLAGS and CXXFLAGS from the environment are used to initialize CMAKE_C_FLAGS only if the CMakeLists.txt or cmake command line does not define CMAKE_C_FLAGS or CMAKE_CXX_FLAGS. So, there is an argument to also remove

set(CMAKE_C_FLAGS   "-Waddress -Wtype-limits -Wsign-compare")
set(CMAKE_CXX_FLAGS "-Waddress -Wtype-limits -Wsign-compare")
jaromil commented 5 years ago

I agree to remove all the cmake flags. For warnings and debugging purposes I have already setup special flags in the CI builds so we will still have visibility for those.