Commit Graph

90 Commits (c4ca4be91e0f38646fa391aaca6fd58e505be4c4)

Author SHA1 Message Date
наб cbac182edf Add and build mimalloc at 07c6e60a5a3bd7de09e4a170cd97bafba59cfafd 2020-07-12 02:37:07 +00:00
whitequark a80a0337a5 Disable OpenMP.
This is unfortunate, but OpenMP is not available on some toolchains
(most MinGW builds) and, more importantly, breaks the distribution
model we use on Windows, which is a single self-contained executable.

Leave the OpenMP disabled by default everywhere so that we don't have
any second-class platforms where SolveSpace is slower than on first-
class ones.

Fixes #631.
2020-06-21 01:15:28 +00:00
whitequark 521473ee4b Win32: use CRT heap instead of our own.
Historically SolveSpace used its own heap on Windows since it gave
better control and debugging options, but a lot of development these
days happens on Linux, where that heap was a stub around malloc/free,
and also Windows debugging tools got a lot better.

In terms of immediate benefit, this commit fixes heap corruption
on Windows introduced in commits b4e1ce44 and 47e82798, caused
by allocating with HEAP_NO_SERIALIZE in parallel from OpenMP threads.
Without HEAP_NO_SERIALIZE there's no performance benefit to keeping
our own heap, either.

The vl() function is also removed because for development there are
better tools now, and the only place where it was permanently called
from became a no-op, since temporary heap always validates after
FreeAllTemporary() recreates it.
2020-05-10 05:35:42 +00:00
whitequark 74103eee81 CMake: expand sanitizer support to include TSan. 2020-05-10 02:52:39 +00:00
whitequark 47e82798da CMake: detect OpenMP and use if available.
This is a missing part of commit b4e1ce44.
2020-05-09 19:46:16 +00:00
nabijaczleweli 645353cbdc Force SSE2 floats for i686 targets
Both GCC and Clang use x87 instructions by default on 32-bit x86
targets, but the loss of precision resulting from that has yielded
crashing tests (see referenced issue), and it can be safely assumed
there are very few CPUs that both don't support SSE2 and are expected to
run SolveSpace

This commit also removes a now-redundant check for 32-bit Windows
against TARGET, which doesn't seem to be actually set by CMake at all

Ref: #565
2020-03-24 17:31:21 +00:00
nabijaczleweli e355a095c4 Force vendor zlib, png, and FreeType on Win32, too
This has lead to linker problems if the environment does have standard
versions of zlib/png (like from MSYS2), see discussion in referenced
issue

Closes #559
2020-03-15 03:03:24 +00:00
whitequark 0b786e6e2b CMake: review minimum required CMake version.
It turns out that using cmake_policy(VERSION) is effectively same as
using cmake_minimum_required(VERSION) because it is a hard error
if the CMake running the script is too old. As such, replace 22525e65
with two changes:
  * Set the minimum required version to 3.7.2 (Debian stretch),
    which also configures policies.
  * If CMake is at least as new as 3.11.0, then set the policies
    according to that version.
This should actually have the intended behavior.
2019-12-02 18:51:58 +00:00
whitequark 22525e6515 CMake: update policy to 3.11.
In particular this enables linking with GLVND on Linux by default.
2019-11-26 11:23:37 +00:00
whitequark fb536a155d Test for -ffile-prefix-map support instead of comparing versions.
Comparing versions is not viable because Apple clang has its own
versioning scheme which is also undocumented.
2019-11-24 18:55:46 +00:00
whitequark 690f87cf4a On GNU-compatible compilers, avoid embedding paths into binaries.
This is helpful for reproducible builds, and also makes it easier
to debug binaries built on another system.
2019-11-23 16:57:35 +00:00
Koen Schmeets b5ccf5acf5 macOS: fix CMake Xcode generator.
This is done by setting `CMAKE_RUNTIME_OUTPUT_DIRECTORY` to `$<1:${CMAKE_BINARY_DIR}/bin>`
2019-11-23 13:20:45 +00:00
Ruevski 260769c03b Win32: Restore Windows XP Compatibility
By setting WINVER=0x0501 (Windows XP) in CMakeLists.txt and adding a few
missing defines in guiwin.cpp and configuring OPENGL=1 in CMake
Solvespace (3.0~25b6eba1) compiles and works perfectly on Windows XP.
Tested with MinGW GCC-6.3.0-1
2019-05-23 14:42:55 +00:00
whitequark e9b9dca2ca Win32: use native OpenGL drivers, if available.
After this commit, if the target system does have modern OpenGL
drivers installed, ANGLE is configured to use them, bypassing most
translation (shaders still have to be translated from ESSL to GLSL).

If there are no OpenGL drivers, such as if the graphics drivers were
installed via Windows Update, DirectX translation is still used. This
results in a very noticeable startup delay and minor performance
degradation.

In addition it is no longer necessary to build with -DOPENGL=1 to be
able to run the binary in wine; everything works out of the box.
Before, wine's incomplete HLSL translator would crash.

This change required renaming the variable `texture` in shaders,
since it shadows the Core GLSL function with the same name, and ANGLE
translates texture2D() calls to texture() calls.
2019-05-23 10:58:31 +00:00
whitequark e7b75f19c3 Revert "CMake: replace GetGitCommitHash with .gitattributes and $Id$."
This reverts commit c962357b35.

$Id$ inserts the SHA1 of the *blob*, not the *commit*, and is
therefore completely worthless.
2019-05-01 08:32:59 +00:00
Sergiusz Bazanski 3a3a2755bf Implement Q3DO export.
We plan to use flatbuffers in the future for the next generation of
the .slvs file format, so flatbuffers are built unconditionally; and
the Q3DO exporter itself is tiny.
2019-03-28 08:53:37 +00:00
whitequark c962357b35 CMake: replace GetGitCommitHash with .gitattributes and $Id$. 2019-02-10 09:41:11 +00:00
whitequark efc3da4579 CMake: add an ENABLE_CLI flag. 2018-07-18 11:49:06 +00:00
whitequark c1f1c7c409 Add a platform abstraction for 6-DOF input devices.
This commit mostly just moves code around.
2018-07-18 01:05:19 +00:00
whitequark ba71dba024 CMake: use correct gtkmm version constraint.
Many GL APIs appeared in GTK in version 3.16, but in gtkmm only in
version 3.18.
2018-07-12 12:19:59 +00:00
whitequark f37881a2e3 macOS: bundle and statically link external dependencies.
This fixes numerous linking issues where updated system libraries
on macOS cause errors on startup in newer OS versions.
2018-07-12 11:15:31 +00:00
whitequark c5a3b43665 CMake: support sanitizers on gcc builds, too.
This also fixes Travis Linux builds.
2018-07-11 04:52:11 +00:00
whitequark 13695be03a CMake: update required version to 3.2.
We use continue(), which was introduced in 3.2.
2017-11-06 05:40:49 +00:00
whitequark ecb6550b5c Change mentions of OpenGL 2 to OpenGL 3.
We ended up in a confusing state where OpenGL 2 (like in "gl2")
actually refers to OpenGL ES 2, which roughly corresponds to
OpenGL 3. Rectify that.
2017-04-06 07:20:50 +00:00
whitequark 6b67cfe63f Except when using OpenGL ES 2, use OpenGL 3.2+ Core profile.
This is primarily done to lower the GTK version dependency below
GTK 3.22, since GTK 3.22 is unlikely to be widely availale any
time soon.
2017-01-13 23:43:02 +00:00
Elvira Khabirova 4f04406121 Implement a gettext .po file parser. 2017-01-05 12:14:40 +00:00
whitequark 934f33f4c0 Update zlib, libpng and Freetype submodules to latest versions.
In particular this fixes an issue with the Freetype build system
where re-running CMake would rebuild it from scratch every time.
2017-01-03 01:28:07 +00:00
whitequark 6b8f937894 Win32: fix compatibility with MSVC x64 builds. 2017-01-03 00:52:24 +00:00
whitequark e127b28a2d CMake: allow building the CLI without the GUI. 2017-01-02 22:13:20 +00:00
whitequark 9253e5f229 GTK: update gtkmm dependency.
Pre-3.22 gtkmm doesn't have Gtk::GLArea::set_use_es(), which we
require.
2017-01-02 20:46:18 +00:00
whitequark 7dbbd75969 Drop support for GTK 2.
It's a deprecated platform that has weird OpenGL-related bugs and
is incompatible with using EGL anyway. It was clear we're going
to drop it, the only question was when. Answer: now.
2017-01-02 16:20:12 +00:00
whitequark d1ddc6ee07 Win32: fix inclusion of manifest, to get back visual styles.
This commit fixes four issues:
  * Instead of WRITE,APPEND, resource.rc was generated using
    WRITE,WRITE, which erased #include <windows.h> and prevented
    any symbolic definitions (like RT_MANIFEST) from working.
    This silently included them using a string type instead,
    which did nothing.
  * WINVER is bumped to Win7, since that's what we target now.
  * Index of RT_MANIFEST is changed to 2, since that's what
    it has to be when ISOLATION_AWARE_ENABLED is defined.
  * Platform is not restricted to X86 in manifest, since there
    is no point in doing so.
2016-12-04 20:33:46 +00:00
whitequark 6989a3d068 CMake: Cairo is required for CLI, not just tests. 2016-12-04 19:05:51 +00:00
whitequark 9301dec98d Use the same code for loading resources in all executables.
All of our executables need resources; e.g. the vector font is
a resource and it is necessary for generation. Before this commit,
the GUI executable loaded the resources in a nice way, and everything
else did it in a very ad-hoc, fragile way.

After this commit, all executables are placed in <build>/bin and
follow the same algorithm:
  * On Windows, resources are compiled and linked into every
    executable.
  * On Linux, resources are copied into <build>/res (which is
    tried first) and <prefix>/share/solvespace (which is tried
    second).
  * On macOS, resources are copied into <build>/res (which is
    tried first) and <build>/bin/solvespace.app/Contents/Resources
    (which is tried second).

In practice this means that we can add as many executables as we want
without duplicating lots of code. In addition, on macOS, we can
place supplementary executables into the bundle, and they can use
resources from the bundle transparently.
2016-11-28 06:18:42 +00:00
whitequark 8dc60f61c1 Fix Windows build with -DOPENGL=1.
This is mostly useful when testing the Windows functionality
on Linux, as wine is currently unable to compile the shaders
that ANGLE outputs.
2016-11-19 05:14:06 +00:00
whitequark d3f2ac7513 Remove most dependencies on config.h.
The only thing we need it anymore is the package version and platform
configuration, so only include it for that. As a result, less files
are rebuilt when the git commit changes and config.h is regenerated.
2016-11-19 01:00:11 +00:00
whitequark 0ae0343fc7 Add a simple benchmarking harness. 2016-11-18 13:55:24 +00:00
whitequark c8ff17f4a2 Add OpenGL 2 support on Windows using ANGLE.
This commit performs two main changes:
  * Alters the shaders to use only strictly conformant GLSL 2.0.
  * Alters the Windows UI to use ANGLE via GL ES 2.0 and EGL 1.4.

This commit also drops official support for Windows XP, since ANGLE
requires a non-XP toolset to build. It is still possible to build
SolveSpace for Windows XP using:

  cmake -T v120_xp -DOPENGL=1
2016-11-18 11:38:45 +00:00
whitequark d151eb56fc CMake: reject in-tree builds.
We do not support clobbering the source tree with build products,
nor recommend this in any documentation, and this already leads to
weird bugs with the resource system. Show an explicit error in this
case to avoid confusion.
2016-11-03 07:25:57 +00:00
whitequark fbe2705ebe CMake: disable unsigned overflow sanitizer check.
This seems too aggressive for us; it breaks the hash function and
I would prefer to not add tool-specific exclusions in the code.
2016-08-07 19:27:58 +00:00
whitequark 068ed2816a CMake: fix typo. 2016-08-07 17:33:27 +00:00
whitequark a2a50927e9 CMake: make code coverage work with Clang.
Clang uses a slightly different .gcno/.gcda format than GCC, and
it is necessary to point lcov to `llvm-cov gcov` instead of `gcov`.
2016-08-01 05:39:18 +00:00
whitequark 42d3ec9917 CMake: finish Clang sanitizer support.
This makes ENABLE_SANITIZERS a proper cached variable, removes some
spurious failures and configures asan/ubsan to die on an error.
2016-08-01 05:39:18 +00:00
whitequark 2fdbabc13c Add statement/condition coverage measurement for the test suite.
We're using gcov+lcov, since these tools appear to be the only
usable ones that use the SC/CC metric; and measuring just the line
coverage would be practically criminal negligence.

gcov only works with GCC and Clang, and MSVC's own coverage
measurement tools are not up to the task; so MSVC is out of luck.
2016-08-01 02:19:06 +00:00
whitequark 5e63d8301e Add a simple harness for automated, headless testing.
This commit alters the build system substantially; it adds another
platform, `headless`, that provides stubs in place of all GUI
functions, and provides a library `solvespace_headless` alongside
the main executable. To cut down build times, only the few files
that have #if defined(HEADLESS) are built twice for the executable
and the library; the rest is grouped into a new `solvespace_cad`
library. It is not usable on its own and just serves for grouping.

This commit also gates the tests behind a -DENABLE_TESTS=ON CMake
option, ON by default (but suggested as OFF in the README so that
people don't ever have to install cairo to build the executable.)

The tests introduced in this commit are (so far) rudimentary,
although functional, and they serve as a stepping point towards
introducing coverage analysis.
2016-08-01 00:48:37 +00:00
whitequark 6963c7e25b Add Cairo (and, transitively, Pixman) dependencies. 2016-08-01 00:48:37 +00:00
whitequark 7f0083aa1d CMake: correctly use if(STREQUAL).
If an operand is a string, it should be quoted to prevent expansion.
This doesn't matter with "GNU", but does with "MSVC" (which expands
to "YES").
2016-08-01 00:48:37 +00:00
whitequark bcd8c3e790 CMake: do not leak solvespace-specific compiler flags.
Before this commit, our warning flags and definitions were leaking
into the vendored dependencies.
2016-07-25 04:22:03 +00:00
whitequark 6607a48357 CMake: refactor inclusion of external libraries.
This commit makes common external packages always be included through
find_package to eliminate differences in variables set, wraps
find_package for vendored libraries on Windows to factor out common
code, and removes miscellaneous useless code elsewhere in dependency
handling.

This also fixes a problem where pkg-config would pick up `build`
libraries instead of `host` when cross-compiling.
2016-07-25 04:22:02 +00:00
whitequark 7265121b24 Refactor GlOffscreen; remove the GLEW dependency.
It was never really needed, since both Linux and OS X, where
GlOffscreen is used, guarantee that the API we need is present,
on all OS versions we're interested in.

Also, reorganize GlOffscreen consistently with the rest of our
codebase, and don't use RAII for OpenGL resource management because
of its requirement for an active context.
2016-07-25 04:21:55 +00:00