Commit Graph

2623 Commits

Author SHA1 Message Date
Ray Molenkamp 43e4d6e5b1 CMake/Windows: Compile GMP library as fat library 2020-10-20 13:04:53 -06:00
Sergey Sharybin 1c08ab4535 CMake: Compile GMP library as fat library
The idea behind this is to compile all versions of functions,
and let the library to pick the best at runtime.

Attempting to fix T81835
2020-10-20 16:18:59 +02:00
Bastien Montagne 580fe9f5f8 Fix (unreported) install_deps: wrong version number for llvm in some cases.
Version reported by package manager is not always satisfying (on Debian
testing currently e.g. `llvm-dev` is reported as `9.0`, when exact one
is actually `9.0.1`, this break CMake build of Blender then).

Just use version reported by `llvm-config` instead, when using
distribution packages.
2020-10-20 12:52:17 +02:00
Ankit Meel 4fb67ae809 CMake/macOS: use system OpenAL for the time being.
Revert part of {rB83124856d05ee4da605ab247e6}
2020-10-19 22:05:56 +05:30
Ankit Meel 83124856d0 Cmake/macOS: strictly disallow searching in frameworks
This is a stricter version of the change made in
{rBbb872b25f219d1a9bc2446228b6dc}

Cmake must never look into Frameworks when the system
library guards (`without_system_libs_begin`/`without_system_libs_end`)
are present.

OpenAL didn't follow this and OpenAL.framework in Xcode would be used.
The Cmake's `FindOpenAL.cmake` looks for both library (in this case,
the .framework file), and include dir.
Precompiled libraries don't contain the former. So `find_package`
cannot be used, or it becomes the hack that {rBb2c707747da9} removed.
So hardcode the include dir path, and other variables.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D9267
2020-10-19 18:47:35 +05:30
Ankit Meel bb872b25f2 CMake/macOS: Search for headers in Frameworks last.
https://devtalk.blender.org/t/libpng-version-mismatch/15799/

By default, `CMAKE_FIND_FRAMEWORK` is `FIRST`.

CMake searches headers and libraries separately. So library is found
in LIBDIR, and headers like those in Mono are detected before the
headers in LIBDIR, and we get a version mismatch.

So set the priority of Frameworks to `LAST`.

https://gitlab.kitware.com/cmake/cmake/-/issues/18921
https://gitlab.kitware.com/cmake/cmake/-/issues/16427

{rBbac91956ae97} tried to fix the same issue, but it didn't work.
It's fine to keep the changes made there, just removing the comment
that may give false sense of security.
2020-10-16 13:41:29 +05:30
Ankit Meel 3ffe65a7fb CMake/macOS: Restore TIFF's optional status.
{rB1f6b7387ad01}
2020-10-16 13:41:26 +05:30
Ankit Meel bac91956ae CMake/macOS: set package_ROOT for PNG, JPEG, TIFF
https://devtalk.blender.org/t/libpng-version-mismatch/15799/

In this case, CMake finds libraries in `LIBDIR`, but picks headers from
`/Library/Frameworks/` (Mono framework).

CMP0074 is already enabled, so use it.
2020-10-15 18:49:45 +05:30
Eric Cosky dd3b047f8b Windows/CMake:Support BLENDER_USER_SCRIPTS in IDE
This diff adds support for respecting the `BLENDER_USER_SCRIPTS`
environment variable when setting up the IDE environment.

Previously the scripts from the users profile folder were always
used even when this variable was set, leading to the possibility
of the wrong scripts being visible in the IDE.

Differential Revision: https://developer.blender.org/D9189
Reviewed By: Ray Molenkamp
2020-10-13 08:45:22 -06:00
Patrick Mours 3bb3b26c8f Cycles: Add CUDA 11 build support
With this patch the build system checks whether the "CUDA10_NVCC_EXECUTABLE" CMake
variable is set and if so will use that to build sm_30 kernels. Similarily for sm_8x kernels it
checks "CUDA11_NVCC_EXECUTABLE". All other kernels are built using the default CUDA
toolkit. This makes it possible to use either the CUDA 10 or CUDA 11 toolkit by default and
only selectively use the other for the kernels where its a hard requirement.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D9179
2020-10-13 15:15:44 +02:00
Ankit Meel 666485f38c CMake/macOS: find ZLib before setting CMAKE_PREFIX_PATH
https://devtalk.blender.org/t/building-blender-on-macos-fails/15756/

In some cases, CMake finds the Zlib supplied with OpenCollada
pre-compiled libraries, and not the system one.
2020-10-13 16:34:43 +05:30
Ankit Meel c68338ee89 CMake/macOS/OpenMP: copy the library near tests.
For multi-config generators, tests are in `bin/tests/<config>` folder.
and OpenMP cannot be found at `@executable_path/../Resources/lib`.
So create that folder and put the library there to be used by tests.

It is not ideal to copy the library around. When minimum CMake version
is changed to 3.12, FindOpenMP by CMake can be used for this whole
block of code. Then a nice rpath based solution can be used.
2020-10-10 19:31:03 +05:30
Ankit Meel c735aca42e CMake/macOS/OpenMP: allow use of LLVM-Clang with OpenMP.
The "Apple" part is guaranteed by the platform file.
"Clang" is enough to differentiate it from other compilers.

Came across this due to the custom built LLVM toolchain I'm using.
2020-10-10 16:28:42 +05:30
Ankit Meel 50ffcf12b2 Cleanup: CMake/macOS: remove boost from OIIO libs.
Introduced by me in {rB1f6b7387ad0177c1dec9bb83b7}.
2020-10-09 20:39:58 +05:30
Bastien Montagne e340f943f5 Fix (unreported) install_deps: broken compilation of OIDN.
When OIDN version was bumped recently the required dependency to build
it (ISPC) was not updated accordingly.
2020-10-09 17:07:16 +02:00
Andreas Bergmeier 9aef0283a0 install_deps: Do not request elevated rights when creating directory in owned directory.
This only creates elevated directory when necessary.

Reviewed By: mont29

Differential Revision: https://developer.blender.org/D1596
2020-10-09 17:05:03 +02:00
Ankit Meel 1f6b7387ad CMake/macOS: Remove _LIBPATH, avoid link_directories.
After tests were bundled in a single executable and cycles and libmv
created their own tests, the warnings on macOS have gone over 800.
The reason is setting `*_LIBRARIES` to names of the libraries
and later using `link_directories` to link them properly.

https://cmake.org/cmake/help/latest/command/link_directories.html

> Note This command is rarely necessary and should be avoided where
> there are other choices. Prefer to pass full absolute paths to
> libraries where possible, since this ensures the correct library
> will always be linked. The find_library() command provides the
> full path, which can generally be used directly in calls to
> target_link_libraries().

Warnings like the following popup for every target/executable,
for every library it links to.
```
ld: warning: directory not found for option
'-L/Users/me/blender-build/blender/../lib/darwin/jpeg/lib/Debug'
```

The patch completes a step towards removing `link_directories` as
mentioned in TODO at several places.
The patch uses absolute paths to link libraries and removes
all `*_LIBPATH`s except `PYTHON_LIBPATH` from
`platform_apple.cmake` file. (The corner case where it's used seems
like dead code. Python is no longer shipped with that file structure.)

Also, unused code for LLVM-3.4 has been removed.
Also, guards to avoid searching libraries in system directories have
been added.

`APPLE` platform now no longer needs `setup_libdirs`,
`cycles_link_directories`, and `link_directories`.
The number of warnings now is less than 100, most of them being
deprecation ones in dependencies.

This patch depended on {rBb746179d0add}, {rB2fdbe4d05011},
{rB402a4cadba49} and {rBd7f482f88ecb}.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D8855
2020-10-09 19:41:58 +05:30
Andreas Bergmeier 2a39b6d4d1 Cleanup: spelling
Ref D9138
2020-10-09 18:08:38 +11:00
Patrick Mours 3df90de6c2 Cycles: Add NanoVDB support for rendering volumes
NanoVDB is a platform-independent sparse volume data structure that makes it possible to
use OpenVDB volumes on the GPU. This patch uses it for volume rendering in Cycles,
replacing the previous usage of dense 3D textures.

Since it has a big impact on memory usage and performance and changes the OpenVDB
branch used for the rest of Blender as well, this is not enabled by default yet, which will
happen only after 2.82 was branched off. To enable it, build both dependencies and Blender
itself with the "WITH_NANOVDB" CMake option.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D8794
2020-10-05 15:03:30 +02:00
Campbell Barton 3e101759b1 Cleanup: remove arguments to ENDIF in CMake files
This is an old convention that hasn't been used
by Blender or CMake distributed Find* files for a long time.
2020-10-05 16:26:06 +11:00
Campbell Barton 4053fa9fcb Fix invalid version check in 'project_source_info'
Own error in 870fcb3857
2020-10-02 13:46:41 +10:00
Campbell Barton 41d2d6da0c Cleanup: pep8 (indentation, spacing, long lines) 2020-10-02 11:59:16 +10:00
Campbell Barton bab9de2a52 Cleanup: pep8, blank lines 2020-10-02 11:59:16 +10:00
Campbell Barton 28ebe827e6 Cleanup: trailing space 2020-10-02 11:59:16 +10:00
Ankit Meel d5353eea5b Cleanup: CMake/FFmpeg: Fix typo in message/comment
Code added in the last commit {rB2fdbe4d0501114c716fd12bc}.
2020-09-29 00:40:31 +05:30
Ankit Meel 2fdbe4d050 CMake/Find packages: add FindFFmpeg.cmake module.
The behaviour is a bit different from other find modules:
`FFMPEG_FIND_COMPONENTS` should contain the
list of required libraries before calling `find_package(FFmpeg)`.
If not set, a default set of most common libraries is searched for:
`avcodec avdevice avfilter avformat avutil`
http://ffmpeg.org/download.html

Ref D8855

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D8918
2020-09-29 00:33:13 +05:30
Ankit Meel 8fb806ab15 Revert "Generate Xcode scheme files during configuration."
This reverts commit 5eb5978043.

The change was problematic:
*Advanced users may prefer managing schemes manually and adding only
a few that they need, instead of one for every library/executable
Blender builds.

*If CMake creates schema files, it overwrites the changes a developer
made every time CMake is run. If Xcode creates scheme files, it keeps
settings/ environment variables intact.

If someone runs CMake very frequently, pass
`-DCMAKE_XCODE_GENERATE_SCHEME=ON` to `cmake` while configuring.
2020-09-26 23:17:10 +05:30
Ankit Meel 8d34e81449 Cleanup: CMake config: set options in alphabetical older
No functional change.
2020-09-26 23:17:10 +05:30
Ankit Meel fdf77341cd CMake: Remove duplicate WITH_GMP options.
I didn't realize there were more duplicates while committing
{rBf1fee433be92}.

Original was added in {rB83f8223543f58c3b0881a03b6e9ddffff91}.
Duplicate was added in the merge {rB9e09b5c418c0a436e3c84ccf}.

Ref D8822
2020-09-26 23:13:07 +05:30
Dalai Felinto 538d9bb41d Fixup for license changes
There was still a cmake file that was explicitly referring to the GPL3 license.

This was failing only on Windows.
2020-09-24 15:51:47 +02:00
Ankit Meel f1fee433be GMP/CMake: Remove duplicate GMP search logic.
Original was added in rB83f8223543f58c3b0881a03b6e9ddffff91.
Duplicate was added in the merge rB9e09b5c418c0a436e3c84ccf.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8822
2020-09-24 15:20:07 +05:30
Ray Molenkamp b21e2cfd03 CMake: Enable WITH_POTRACE by default
All platforms have landed the libs, this can be on
by default now.
2020-09-22 08:03:50 -06:00
Sergey Sharybin 6836a40287 Make deps: Enable fPIC for Linux
Similar to D8823.
2020-09-21 12:53:24 +02:00
Ray Molenkamp 104df2453a deps: fix build issue on windows.
Windows does not build libxml2 so the dependency recently
added for mac caused a cmake error.
2020-09-18 13:52:06 -06:00
Brecht Van Lommel 7b988188dc Fix T79929: crashes with Cycles denoising on older Macs
This was a bug in OpenImageDenoise, upgrade to latest 1.2.3 which has the fix.
This in turn required a newer ispc version.

Differential Revision: https://developer.blender.org/D8892
2020-09-18 18:11:32 +02:00
Brecht Van Lommel 007e90e8c0 Fix T78793, T79707: Cycles crash on macOS with older CPUs
Embree static libraries need additional linking flags to avoid SSE and
AVX symbols getting mixed up.
2020-09-18 18:10:49 +02:00
Ankit Meel 402a4cadba CMake/LLVM: Add INCLUDE_DIRS to find package.
Ref {D8855}

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D8919
2020-09-18 19:14:01 +05:30
Ankit Meel b746179d0a CMake/OpenSubdiv: Rename INCLUDE_DIR -> INCLUDE_DIRS.
Ref {D8855}

Unix and Apple platform files use find_package(OpenSubdiv) which sets
`OPENSUBDIV_INCLUDE_DIR` as an advanced variable, as well as
`OPENSUBDIV_INCLUDE_DIRS` which should be used usually.
Windows sets `OPENSUBDIV_INCLUDE_DIR` which is used by the rest
of the code.

This patch renames it to `_DIRS` everywhere, for it to be like other
similar variables.

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D8917
2020-09-18 19:12:26 +05:30
Sebastián Barschkis 08a3f01ddc macOS: Added potrace in platform apple cmake
Ref T80818

Reviewed By: brecht

Maniphest Tasks: T80818

Differential Revision: https://developer.blender.org/D8922
2020-09-17 17:32:39 +02:00
Ankit Meel f37c83a12b CMake/Potrace: Fix capitalization, silence warning.
The `find_package()` callers expect the library name as `Potrace`, not
`POTRACE`.

Reviewed By: LazyDodo

Differential Revision: https://developer.blender.org/D8923
2020-09-17 19:45:20 +05:30
Brecht Van Lommel 532ac1163c Tests: bundle tests for some modules in their own executables
The ffmpeg, guardedalloc and blenlib are quite isolated and putting them in
their own executable separate from blender_test is faster for development than
linking the entire blender_tests executable.

For Cycles, this also bundles all the unit tests into one executable.

Ref T79958

Differential Revision: https://developer.blender.org/D8714
2020-09-17 12:29:19 +02:00
Brecht Van Lommel f9fcb25d52 CMake: clean up setting of platform specific linker flags
Set flags directly on the target, and use common function for all cases.
This refactoring helps with the next commit for test executables.

Ref D8714
2020-09-17 12:29:19 +02:00
Sergey Sharybin 157cd6c6e8 Make deps: Compile own nasm for Linux
This solves annoyance that the official RPM repository of nasm requires
newer version of rpm tool compared to what is shipped by default with
centOS 7.

Differential Revision: https://developer.blender.org/D8905
2020-09-17 11:02:27 +02:00
Bastien Montagne c5c22d1ce1 Install_deps: update to add pugixml and potrace new deps.
Also fixed OpenVDB maximum version, it appears that even 7.1 is not
compatible with 7.0?

Re T80818 and D8628.
2020-09-16 11:23:58 +02:00
Ankit Meel a4c5811e21 ASan/macOS: fix incomplete C/CXX compiler flags.
While testing for {rB40dcf686f04f}, compiler flags got mixed up and
non-working ASan configuration was committed.

Platform file, which is `include`d after the `CMAKE_C_FLAGS_DEBUG` etc.,
are set, overwrites those flags instead of appending to them. To fix this,
`PLATFORM_CFLAGS` is used to pass the `-fsanitize=*` flags to the C/C++
compiler.

Tested on fresh build using both Xcode and Ninja, with & without ccache.

Also silence a clang warning for multi-config generators:
the object size sanitizer has no effect at -O0, but is explicitly
enabled: -fsanitize=object-size [-Winvalid-command-line-argument]

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D8879
2020-09-16 02:18:59 +05:30
Ankit 84032fd110 GMP/macOS: silence "PIE disabled" linker warning.
The change builds GMP with `--with-pic` flag on non-arm architecture.

The warning:
ld: warning: PIE disabled. Absolute addressing
(perhaps -mdynamic-no-pic) not allowed in code signed PIE, but used in
___gmpn_divexact_1 from lib/darwin/gmp/lib/libgmp.a(dive_1.o). To fix
this warning, don't compile with -mdynamic-no-pic or link with
-Wl,-no_pie

Reviewed By: sebbas

Differential Revision: https://developer.blender.org/D8823
2020-09-16 02:05:51 +05:30
Ray Molenkamp 2eec6ec793 Deps: Add potrace as a new library dependency
For work the GP team plans to land soon (T79877) potrace was taken
on as an additional optional dependency.

This diff adds building the library to the deps builder and takes
care of the integration into the build-system with the `WITH_POTRACE`
cmake switch.

Differential Revision: https://developer.blender.org/D8662

Reviewed by: brecht, sergey
2020-09-15 13:16:37 -06:00
Campbell Barton dd25d47e8a Cleanup: add missing headers to CMake, formatting 2020-09-15 22:53:44 +10:00
Sebastián Barschkis 177759d818 Make deps: Updated required list of dependencies for macOS
It was possible to drop `nasm` from the list of required macOS dependencies. However, `pkg-config` had to be added - it was required before but probably no one noticed this.

In order to build `external_clang` successfully, `external_xml2` had to be added to the clang dependencies (`c-index-test` was failing).

Note: On Linux `make deps` still seems to require `nasm` installed via apt.

Reviewed By: sergey

Differential Revision: https://developer.blender.org/D8870
2020-09-14 17:38:06 +02:00
Tyler Alden Gubala 07d7028dd0 CMake: various fixes for building Python module
* Don't link against Mesa OpenGL software emulation libraries from the
  lib folder, they are not intended to be used for building, only install.
* Don't use static OpenMP library by default, it's usually not built to
  work in shared libraries.
* Disable jemalloc on all platforms, the reason it fails is not specific
  to Linux.

Differential Revision: https://developer.blender.org/D8827
2020-09-10 19:40:54 +02:00