2016-02-17 06:22:34 +00:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2016-07-24 13:55:33 +00:00
|
|
|
# configuration
|
2015-03-18 17:02:11 +00:00
|
|
|
|
2015-03-29 00:33:46 +00:00
|
|
|
include_directories(
|
2016-02-19 10:15:59 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR})
|
2015-03-29 00:33:46 +00:00
|
|
|
|
|
|
|
set(HAVE_SPACEWARE ${SPACEWARE_FOUND})
|
2016-02-19 10:15:59 +00:00
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
2015-03-29 00:33:46 +00:00
|
|
|
|
|
|
|
# platform utilities
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
set(util_SOURCES
|
2016-04-21 18:24:49 +00:00
|
|
|
platform/w32util.cpp)
|
2015-03-29 00:33:46 +00:00
|
|
|
else()
|
|
|
|
set(util_SOURCES
|
2016-04-21 18:24:49 +00:00
|
|
|
platform/unixutil.cpp)
|
2015-03-29 00:33:46 +00:00
|
|
|
endif()
|
|
|
|
|
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 04:16:18 +00:00
|
|
|
if(APPLE)
|
|
|
|
set(util_LIBRARIES
|
|
|
|
${APPKIT_LIBRARY})
|
|
|
|
endif()
|
|
|
|
|
2015-03-29 00:33:46 +00:00
|
|
|
# libslvs
|
|
|
|
|
|
|
|
set(libslvs_SOURCES
|
|
|
|
util.cpp
|
|
|
|
entity.cpp
|
|
|
|
expr.cpp
|
|
|
|
constraint.cpp
|
|
|
|
constrainteq.cpp
|
2017-03-09 14:44:32 +00:00
|
|
|
system.cpp
|
|
|
|
platform/platform.cpp)
|
2015-03-29 00:33:46 +00:00
|
|
|
|
|
|
|
set(libslvs_HEADERS
|
2017-03-09 14:44:32 +00:00
|
|
|
solvespace.h
|
|
|
|
platform/platform.h)
|
2015-03-29 00:33:46 +00:00
|
|
|
|
2015-03-18 17:02:11 +00:00
|
|
|
add_library(slvs SHARED
|
2015-03-29 00:33:46 +00:00
|
|
|
${libslvs_SOURCES}
|
|
|
|
${libslvs_HEADERS}
|
|
|
|
${util_SOURCES}
|
|
|
|
lib.cpp)
|
|
|
|
|
|
|
|
target_compile_definitions(slvs
|
|
|
|
PRIVATE -DLIBRARY)
|
|
|
|
|
|
|
|
target_include_directories(slvs
|
2016-02-19 10:15:59 +00:00
|
|
|
PUBLIC ${CMAKE_SOURCE_DIR}/include)
|
2015-03-29 00:33:46 +00:00
|
|
|
|
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 04:16:18 +00:00
|
|
|
target_link_libraries(slvs
|
|
|
|
${util_LIBRARIES})
|
|
|
|
|
2015-03-29 00:33:46 +00:00
|
|
|
set_target_properties(slvs PROPERTIES
|
2016-02-19 10:15:59 +00:00
|
|
|
PUBLIC_HEADER ${CMAKE_SOURCE_DIR}/include/slvs.h
|
2015-03-29 00:33:46 +00:00
|
|
|
VERSION ${solvespace_VERSION_MAJOR}.${solvespace_VERSION_MINOR}
|
|
|
|
SOVERSION 1)
|
|
|
|
|
|
|
|
if(NOT WIN32)
|
|
|
|
install(TARGETS slvs
|
2016-02-17 06:22:34 +00:00
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
2015-03-29 00:33:46 +00:00
|
|
|
endif()
|
|
|
|
|
2016-07-24 13:55:33 +00:00
|
|
|
# solvespace dependencies
|
|
|
|
|
|
|
|
include_directories(
|
|
|
|
${OPENGL_INCLUDE_DIR}
|
|
|
|
${ZLIB_INCLUDE_DIR}
|
|
|
|
${PNG_PNG_INCLUDE_DIR}
|
2016-07-24 16:37:36 +00:00
|
|
|
${FREETYPE_INCLUDE_DIRS}
|
|
|
|
${CAIRO_INCLUDE_DIRS})
|
2016-07-24 13:55:33 +00:00
|
|
|
|
|
|
|
if(SPACEWARE_FOUND)
|
|
|
|
include_directories(
|
|
|
|
${SPACEWARE_INCLUDE_DIR})
|
|
|
|
endif()
|
2015-03-29 00:33:46 +00:00
|
|
|
|
2016-11-16 02:22:10 +00:00
|
|
|
if(OPENGL STREQUAL 2)
|
2016-06-30 15:54:35 +00:00
|
|
|
set(gl_SOURCES
|
|
|
|
render/gl2shader.cpp
|
|
|
|
render/rendergl2.cpp)
|
2016-11-16 02:22:10 +00:00
|
|
|
elseif(OPENGL STREQUAL 1)
|
|
|
|
set(gl_SOURCES
|
|
|
|
render/rendergl1.cpp)
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unsupported OpenGL version ${OPENGL}")
|
2016-06-30 15:54:35 +00:00
|
|
|
endif()
|
|
|
|
|
2015-03-29 00:33:46 +00:00
|
|
|
if(WIN32)
|
|
|
|
set(platform_SOURCES
|
2016-07-25 19:37:48 +00:00
|
|
|
platform/w32main.cpp
|
2016-06-30 15:54:35 +00:00
|
|
|
${gl_SOURCES})
|
2015-07-05 05:45:39 +00:00
|
|
|
|
|
|
|
set(platform_LIBRARIES
|
2016-07-24 13:55:33 +00:00
|
|
|
comctl32
|
|
|
|
${SPACEWARE_LIBRARIES})
|
2015-03-24 06:45:53 +00:00
|
|
|
elseif(APPLE)
|
2016-07-24 13:55:33 +00:00
|
|
|
add_compile_options(
|
2015-03-24 06:45:53 +00:00
|
|
|
-fobjc-arc)
|
|
|
|
|
|
|
|
set(platform_SOURCES
|
2016-04-21 18:24:49 +00:00
|
|
|
platform/cocoamain.mm
|
2016-07-25 19:37:48 +00:00
|
|
|
render/rendergl.cpp
|
2016-06-30 15:54:35 +00:00
|
|
|
${gl_SOURCES})
|
2015-03-24 06:45:53 +00:00
|
|
|
|
2015-03-25 00:31:09 +00:00
|
|
|
set(platform_BUNDLED_LIBS
|
2016-04-08 10:23:39 +00:00
|
|
|
${PNG_LIBRARIES}
|
|
|
|
${FREETYPE_LIBRARIES})
|
2017-01-02 15:47:34 +00:00
|
|
|
else()
|
2015-03-18 17:02:11 +00:00
|
|
|
set(platform_SOURCES
|
2016-04-21 18:24:49 +00:00
|
|
|
platform/gtkmain.cpp
|
2016-07-25 19:37:48 +00:00
|
|
|
render/rendergl.cpp
|
2016-06-30 15:54:35 +00:00
|
|
|
${gl_SOURCES})
|
2015-03-18 17:02:11 +00:00
|
|
|
|
|
|
|
set(platform_LIBRARIES
|
2016-07-24 13:55:33 +00:00
|
|
|
${SPACEWARE_LIBRARIES})
|
|
|
|
|
|
|
|
foreach(pkg_config_lib GTKMM JSONC FONTCONFIG)
|
|
|
|
include_directories(${${pkg_config_lib}_INCLUDE_DIRS})
|
|
|
|
link_directories(${${pkg_config_lib}_LIBRARY_DIRS})
|
|
|
|
list(APPEND platform_LIBRARIES ${${pkg_config_lib}_LIBRARIES})
|
|
|
|
endforeach()
|
2015-03-29 00:33:46 +00:00
|
|
|
endif()
|
|
|
|
|
2017-01-11 02:44:29 +00:00
|
|
|
set(every_platform_SOURCES
|
|
|
|
platform/w32main.cpp
|
|
|
|
platform/gtkmain.cpp
|
|
|
|
platform/cocoamain.mm)
|
|
|
|
|
2016-07-25 19:37:48 +00:00
|
|
|
# solvespace library
|
2015-03-29 00:33:46 +00:00
|
|
|
|
2016-11-29 02:57:41 +00:00
|
|
|
set(solvespace_core_HEADERS
|
2015-03-29 00:33:46 +00:00
|
|
|
dsc.h
|
|
|
|
expr.h
|
|
|
|
polygon.h
|
|
|
|
sketch.h
|
|
|
|
solvespace.h
|
|
|
|
ui.h
|
2017-03-09 14:44:32 +00:00
|
|
|
platform/platform.h
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
render/render.h
|
2016-06-30 15:54:35 +00:00
|
|
|
render/gl2shader.h
|
2015-03-29 00:33:46 +00:00
|
|
|
srf/surface.h)
|
|
|
|
|
2016-11-29 02:57:41 +00:00
|
|
|
set(solvespace_core_SOURCES
|
2015-03-29 00:33:46 +00:00
|
|
|
bsp.cpp
|
|
|
|
clipboard.cpp
|
2016-06-28 08:48:06 +00:00
|
|
|
confscreen.cpp
|
2015-03-29 00:33:46 +00:00
|
|
|
constraint.cpp
|
|
|
|
constrainteq.cpp
|
|
|
|
describescreen.cpp
|
2016-06-28 08:48:06 +00:00
|
|
|
draw.cpp
|
2015-03-29 00:33:46 +00:00
|
|
|
drawconstraint.cpp
|
|
|
|
drawentity.cpp
|
|
|
|
entity.cpp
|
2017-01-23 00:24:18 +00:00
|
|
|
export.cpp
|
2015-03-29 00:33:46 +00:00
|
|
|
exportstep.cpp
|
|
|
|
exportvector.cpp
|
|
|
|
expr.cpp
|
|
|
|
file.cpp
|
|
|
|
generate.cpp
|
|
|
|
graphicswin.cpp
|
|
|
|
group.cpp
|
|
|
|
groupmesh.cpp
|
2016-04-13 08:43:06 +00:00
|
|
|
importdxf.cpp
|
2015-03-29 00:33:46 +00:00
|
|
|
mesh.cpp
|
|
|
|
modify.cpp
|
|
|
|
mouse.cpp
|
2016-06-24 09:06:30 +00:00
|
|
|
polyline.cpp
|
2015-03-29 00:33:46 +00:00
|
|
|
polygon.cpp
|
Implement a resource system.
Currently, icons, fonts, etc are converted to C structures at compile
time and are hardcoded to the binary. This presents several problems:
* Cross-compilation is complicated. Right now, it is necessary
to be able to run executables for the target platform; this
happens to work with wine-binfmt installed, but is rather ugly.
* Icons can only have one resolution. On OS X, modern software is
expected to take advantage of high-DPI ("Retina") screens and
use so-called @2x assets when ran in high-DPI mode.
* Localization is complicated. Win32 and OS X provide built-in
support for loading the resource appropriate for the user's
locale.
* Embedding strings can only be done as raw strings, using C++'s
R"(...)" literals. This precludes embedding sizable strings,
e.g. JavaScript libraries as used in Three.js export, and makes
git history less useful. Not embedding the libraries means we
have to rely on external CDNs, which requires an Internet
connection and adds a glaring point of failure.
* Linux distribution guidelines are violated. All architecture-
independent data, especially large data such as fonts, is
expected to be in /usr/share, not in the binary.
* Customization is impossible without recompilation. Minor
modifications like adding a few missing vector font characters
or adjusting localization require a complete development
environment, which is unreasonable to expect from users of
a mechanical CAD.
As such, this commit adds a resource system that bundles (and
sometimes builds) resources with the executable. Where they go is
platform-dependent:
* on Win32: into resources of the executable, which allows us to
keep distributing one file;
* on OS X: into the app bundle;
* on other *nix: into /usr/share/solvespace/ or ../res/ (relative
to the executable path), the latter allowing us to run freshly
built executables without installation.
It also subsides the platform-specific resources that are in src/.
The resource system is not yet used for anything; this will be added
in later commits.
2016-04-21 15:54:18 +00:00
|
|
|
resource.cpp
|
2015-03-29 00:33:46 +00:00
|
|
|
request.cpp
|
|
|
|
style.cpp
|
|
|
|
system.cpp
|
|
|
|
textscreens.cpp
|
2016-06-28 08:48:06 +00:00
|
|
|
textwin.cpp
|
2015-03-29 00:33:46 +00:00
|
|
|
toolbar.cpp
|
|
|
|
ttf.cpp
|
|
|
|
undoredo.cpp
|
|
|
|
util.cpp
|
|
|
|
view.cpp
|
2017-03-09 14:44:32 +00:00
|
|
|
platform/platform.cpp
|
Abstract all (ex-OpenGL) drawing operations into a Canvas interface.
This has several desirable consequences:
* It is now possible to port SolveSpace to a later version of
OpenGL, such as OpenGLES 2, so that it runs on platforms that
only have that OpenGL version;
* The majority of geometry is now rendered without references to
the camera in C++ code, so a renderer can now submit it to
the video card once and re-rasterize with a different projection
matrix every time the projection is changed, avoiding expensive
reuploads;
* The DOGD (draw or get distance) interface is now
a straightforward Canvas implementation;
* There are no more direct references to SS.GW.(projection)
in sketch rendering code, which allows rendering to multiple
viewports;
* There are no more unnecessary framebuffer flips on CPU on Cocoa
and GTK;
* The platform-dependent GL code is now confined to rendergl1.cpp.
* The Microsoft and Apple headers required by it that are prone to
identifier conflicts are no longer included globally;
* The rendergl1.cpp implementation can now be omitted from
compilation to run SolveSpace headless or with a different
OpenGL version.
Note these implementation details of Canvas:
* GetCamera currently always returns a reference to the field
`Camera camera;`. This is so that a future renderer that caches
geometry in the video memory can define it as asserting, which
would provide assurance against code that could accidentally
put something projection-dependent in the cache;
* Line and triangle rendering is specified through a level of
indirection, hStroke and hFill. This is so that a future renderer
that batches geometry could cheaply group identical styles.
* DrawPixmap and DrawVectorText accept a (o,u,v) and not a matrix.
This is so that a future renderer into an output format that
uses 2d transforms (e.g. SVG) could easily derive those.
Some additional internal changes were required to enable this:
* Pixmap is now always passed as std::shared_ptr<{const ,}Pixmap>.
This is so that the renderer could cache uploaded textures
between API calls, which requires it to capture a (weak)
reference.
* The PlatformPathEqual function was properly extracted into
platform-specific code. This is so that the <windows.h> header
could be included only where needed (in platform/w32* as well
as rendergl1.cpp).
* The SBsp{2,3}::DebugDraw functions were removed. They can be
rewritten using the Canvas API if they are ever needed.
While no visual changes were originally intended, some minor fixes
happened anyway:
* The "emphasis" yellow line from top-left corner is now correctly
rendered much wider.
* The marquee rectangle is now pixel grid aligned.
* The hidden entities now do not clobber the depth buffer, removing
some minor artifacts.
* The workplane "tab" now scales with the font used to render
the workplane name.
* The workplane name font is now taken from the normals style.
* Workplane and constraint line stipple is insignificantly
different. This is so that it can reuse the existing stipple
codepaths; rendering of workplanes and constraints predates
those.
Some debug functionality was added:
* In graphics window, an fps counter that becomes red when
rendering under 60fps is drawn.
2016-05-31 00:55:13 +00:00
|
|
|
render/render.cpp
|
2016-07-21 20:27:53 +00:00
|
|
|
render/render2d.cpp
|
2015-03-29 00:33:46 +00:00
|
|
|
srf/boolean.cpp
|
|
|
|
srf/curve.cpp
|
|
|
|
srf/merge.cpp
|
|
|
|
srf/ratpoly.cpp
|
|
|
|
srf/raycast.cpp
|
|
|
|
srf/surface.cpp
|
|
|
|
srf/surfinter.cpp
|
|
|
|
srf/triangulate.cpp)
|
|
|
|
|
2016-11-29 02:57:41 +00:00
|
|
|
set(solvespace_core_gl_SOURCES
|
2016-06-28 08:48:06 +00:00
|
|
|
solvespace.cpp)
|
2016-07-25 19:37:48 +00:00
|
|
|
|
2016-11-29 02:57:41 +00:00
|
|
|
add_library(solvespace-core STATIC
|
2015-03-29 00:33:46 +00:00
|
|
|
${util_SOURCES}
|
2016-11-29 02:57:41 +00:00
|
|
|
${solvespace_core_HEADERS}
|
|
|
|
${solvespace_core_SOURCES})
|
2016-07-25 19:37:48 +00:00
|
|
|
|
2016-11-29 02:57:41 +00:00
|
|
|
target_link_libraries(solvespace-core
|
2016-07-25 19:37:48 +00:00
|
|
|
dxfrw
|
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 04:16:18 +00:00
|
|
|
${util_LIBRARIES}
|
2016-07-25 19:37:48 +00:00
|
|
|
${ZLIB_LIBRARY}
|
|
|
|
${PNG_LIBRARY}
|
|
|
|
${FREETYPE_LIBRARY}
|
|
|
|
${Backtrace_LIBRARIES})
|
|
|
|
|
2016-11-29 02:57:41 +00:00
|
|
|
target_compile_options(solvespace-core
|
2016-07-25 22:09:58 +00:00
|
|
|
PRIVATE ${COVERAGE_FLAGS})
|
|
|
|
|
2017-01-04 15:39:27 +00:00
|
|
|
# solvespace translations
|
|
|
|
|
|
|
|
if(HAVE_GETTEXT)
|
2017-01-11 02:44:29 +00:00
|
|
|
set(inputs
|
|
|
|
${solvespace_core_SOURCES}
|
|
|
|
${solvespace_core_HEADERS}
|
|
|
|
${every_platform_SOURCES})
|
2017-02-02 18:09:50 +00:00
|
|
|
|
|
|
|
set(templ_po ${CMAKE_CURRENT_BINARY_DIR}/../res/messages.po)
|
|
|
|
|
2017-01-11 03:08:58 +00:00
|
|
|
set(output_pot ${CMAKE_CURRENT_SOURCE_DIR}/../res/messages.pot)
|
|
|
|
set(output_po ${CMAKE_CURRENT_SOURCE_DIR}/../res/locales/en_US.po)
|
|
|
|
file(GLOB locale_pos ${CMAKE_CURRENT_SOURCE_DIR}/../res/locales/*.po)
|
2017-01-04 15:39:27 +00:00
|
|
|
|
2017-02-02 18:09:50 +00:00
|
|
|
string(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}
|
|
|
|
gen_output_pot ${output_pot})
|
|
|
|
string(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}
|
|
|
|
gen_output_po ${output_po})
|
|
|
|
string(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}
|
|
|
|
gen_locale_pos "${locale_pos}")
|
|
|
|
|
2017-01-04 15:39:27 +00:00
|
|
|
add_custom_command(
|
2017-02-02 18:09:50 +00:00
|
|
|
OUTPUT ${gen_output_pot}
|
2017-01-04 15:39:27 +00:00
|
|
|
COMMAND ${XGETTEXT}
|
2017-01-11 02:44:29 +00:00
|
|
|
--language=C++
|
2017-01-07 06:41:13 +00:00
|
|
|
--keyword --keyword=_ --keyword=N_ --keyword=C_:2,1c --keyword=CN_:2,1c
|
2017-01-05 12:35:50 +00:00
|
|
|
--force-po --width=100 --sort-by-file
|
2017-01-07 06:41:13 +00:00
|
|
|
--package-name=SolveSpace
|
|
|
|
--package-version=${solvespace_VERSION_MAJOR}.${solvespace_VERSION_MINOR}
|
2017-01-04 15:39:27 +00:00
|
|
|
"--copyright-holder=the PACKAGE authors"
|
|
|
|
--msgid-bugs-address=whitequark@whitequark.org
|
2017-02-02 18:09:50 +00:00
|
|
|
--from-code=utf-8 --output=${gen_output_pot} ${inputs}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${gen_output_pot} ${output_pot}
|
2017-01-04 15:39:27 +00:00
|
|
|
DEPENDS ${inputs}
|
2017-01-07 06:41:13 +00:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
2017-01-04 15:39:27 +00:00
|
|
|
COMMENT "Extracting translations"
|
|
|
|
VERBATIM)
|
2017-01-11 03:08:58 +00:00
|
|
|
|
2017-02-02 18:09:50 +00:00
|
|
|
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../res/locales)
|
|
|
|
|
2017-01-11 03:08:58 +00:00
|
|
|
# en_US is a bit special; we pre-fill the msgstrs from msgids, instead of (as would normally
|
|
|
|
# happen) leaving them empty.
|
2017-01-04 15:39:27 +00:00
|
|
|
add_custom_command(
|
2017-02-02 18:09:50 +00:00
|
|
|
OUTPUT ${gen_output_po}
|
2017-01-04 15:39:27 +00:00
|
|
|
COMMAND ${MSGINIT}
|
|
|
|
--locale=en_US --no-translator
|
2017-02-02 18:09:50 +00:00
|
|
|
--output=${templ_po} --input=${gen_output_pot}
|
2017-01-04 15:39:27 +00:00
|
|
|
COMMAND ${MSGMERGE}
|
2017-01-05 12:27:28 +00:00
|
|
|
--force-po --no-fuzzy-matching
|
2017-02-02 18:09:50 +00:00
|
|
|
--output=${gen_output_po} ${output_po} ${templ_po}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${gen_output_po} ${output_po}
|
|
|
|
DEPENDS ${gen_output_pot}
|
2017-01-11 03:08:58 +00:00
|
|
|
COMMENT "Updating en_US translations"
|
2017-01-04 15:39:27 +00:00
|
|
|
VERBATIM)
|
2017-01-11 03:08:58 +00:00
|
|
|
|
|
|
|
foreach(locale_po ${locale_pos})
|
2017-02-02 18:09:50 +00:00
|
|
|
string(REPLACE ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}
|
|
|
|
gen_locale_po ${locale_po})
|
|
|
|
|
2017-01-11 03:08:58 +00:00
|
|
|
get_filename_component(locale_name ${locale_po} NAME_WE)
|
|
|
|
if(locale_name STREQUAL "en_US")
|
|
|
|
continue()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_custom_command(
|
2017-02-02 18:09:50 +00:00
|
|
|
OUTPUT ${gen_locale_po}
|
2017-01-11 03:08:58 +00:00
|
|
|
COMMAND ${MSGMERGE}
|
2017-02-02 18:09:50 +00:00
|
|
|
--no-fuzzy-matching
|
|
|
|
--output=${gen_locale_po} ${locale_po} ${gen_output_pot}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${gen_locale_po} ${locale_po}
|
|
|
|
DEPENDS ${gen_output_pot}
|
2017-01-11 03:08:58 +00:00
|
|
|
COMMENT "Updating ${locale_name} translations"
|
|
|
|
VERBATIM)
|
|
|
|
endforeach()
|
|
|
|
|
2017-01-07 06:41:13 +00:00
|
|
|
add_custom_target(solvespace-translations
|
2017-02-02 18:09:50 +00:00
|
|
|
DEPENDS ${gen_output_pot} ${gen_output_po} ${gen_locale_pos})
|
2017-01-04 15:39:27 +00:00
|
|
|
endif()
|
|
|
|
|
2016-11-29 02:57:41 +00:00
|
|
|
# solvespace graphical executable
|
2016-07-25 19:37:48 +00:00
|
|
|
|
2017-01-02 22:02:37 +00:00
|
|
|
if(ENABLE_GUI)
|
|
|
|
add_executable(solvespace WIN32 MACOSX_BUNDLE
|
|
|
|
${solvespace_core_gl_SOURCES}
|
|
|
|
${platform_SOURCES}
|
|
|
|
$<TARGET_PROPERTY:resources,EXTRA_SOURCES>)
|
|
|
|
|
|
|
|
add_dependencies(solvespace
|
|
|
|
resources)
|
|
|
|
|
|
|
|
target_link_libraries(solvespace
|
|
|
|
solvespace-core
|
|
|
|
${OPENGL_LIBRARIES}
|
|
|
|
${platform_LIBRARIES}
|
|
|
|
${COVERAGE_LIBRARY})
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
set_target_properties(solvespace PROPERTIES
|
|
|
|
LINK_FLAGS "/MANIFEST:NO /SAFESEH:NO /INCREMENTAL:NO /OPT:REF")
|
|
|
|
endif()
|
2015-03-29 00:33:46 +00:00
|
|
|
endif()
|
|
|
|
|
2016-11-29 02:57:41 +00:00
|
|
|
# solvespace headless library
|
|
|
|
|
|
|
|
set(headless_SOURCES
|
|
|
|
platform/headless.cpp
|
|
|
|
render/rendercairo.cpp)
|
|
|
|
|
|
|
|
add_library(solvespace-headless STATIC EXCLUDE_FROM_ALL
|
|
|
|
${solvespace_core_gl_SOURCES}
|
|
|
|
${headless_SOURCES})
|
|
|
|
|
|
|
|
target_compile_definitions(solvespace-headless
|
|
|
|
PRIVATE -DHEADLESS)
|
|
|
|
|
|
|
|
target_include_directories(solvespace-headless
|
|
|
|
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
|
|
|
|
target_link_libraries(solvespace-headless
|
|
|
|
solvespace-core
|
|
|
|
${CAIRO_LIBRARIES})
|
|
|
|
|
|
|
|
target_compile_options(solvespace-headless
|
|
|
|
PRIVATE ${COVERAGE_FLAGS})
|
|
|
|
|
|
|
|
# solvespace command-line executable
|
|
|
|
|
|
|
|
add_executable(solvespace-cli
|
|
|
|
platform/climain.cpp
|
|
|
|
$<TARGET_PROPERTY:resources,EXTRA_SOURCES>)
|
|
|
|
|
|
|
|
target_link_libraries(solvespace-cli
|
|
|
|
solvespace-core
|
|
|
|
solvespace-headless)
|
|
|
|
|
|
|
|
add_dependencies(solvespace-cli
|
|
|
|
resources)
|
|
|
|
|
2016-12-04 20:34:54 +00:00
|
|
|
if(MSVC)
|
|
|
|
set_target_properties(solvespace-cli PROPERTIES
|
|
|
|
LINK_FLAGS "/INCREMENTAL:NO /OPT:REF")
|
|
|
|
endif()
|
|
|
|
|
2016-11-29 02:57:41 +00:00
|
|
|
# solvespace unix package
|
|
|
|
|
|
|
|
if(NOT (WIN32 OR APPLE))
|
2017-01-02 22:02:37 +00:00
|
|
|
if(ENABLE_GUI)
|
|
|
|
install(TARGETS solvespace
|
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
|
|
endif()
|
|
|
|
install(TARGETS solvespace-cli
|
2016-11-29 02:57:41 +00:00
|
|
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# solvespace macOS package
|
|
|
|
|
2015-03-25 00:31:09 +00:00
|
|
|
if(APPLE)
|
2016-11-29 02:57:41 +00:00
|
|
|
set(bundle solvespace)
|
|
|
|
set(bundle_bin ${EXECUTABLE_OUTPUT_PATH}/${bundle}.app/Contents/MacOS)
|
|
|
|
|
|
|
|
add_custom_command(TARGET solvespace POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:solvespace-cli> ${bundle_bin}
|
|
|
|
COMMENT "Bundling executable solvespace-cli"
|
|
|
|
VERBATIM)
|
|
|
|
|
2015-03-25 00:31:09 +00:00
|
|
|
foreach(lib ${platform_BUNDLED_LIBS})
|
2016-01-10 05:20:13 +00:00
|
|
|
get_filename_component(name ${lib} NAME)
|
2016-04-21 17:36:20 +00:00
|
|
|
|
2016-10-10 19:30:34 +00:00
|
|
|
execute_process(COMMAND otool -D ${lib}
|
2015-03-25 00:31:09 +00:00
|
|
|
OUTPUT_VARIABLE canonical_lib OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2016-10-10 19:30:34 +00:00
|
|
|
string(REGEX REPLACE "^.+:\n" "" canonical_lib ${canonical_lib})
|
2016-11-29 02:57:41 +00:00
|
|
|
add_custom_command(TARGET ${bundle} POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${lib} ${bundle_bin}/${name}
|
|
|
|
COMMAND install_name_tool -change ${canonical_lib} @executable_path/${name}
|
|
|
|
$<TARGET_FILE:${bundle}>
|
2016-02-19 10:15:59 +00:00
|
|
|
COMMAND install_name_tool -change ${canonical_lib} @executable_path/${name}
|
2016-11-29 02:57:41 +00:00
|
|
|
$<TARGET_FILE:solvespace-cli>
|
2016-04-21 17:36:20 +00:00
|
|
|
COMMENT "Bundling shared library ${lib}"
|
2016-02-19 10:15:59 +00:00
|
|
|
VERBATIM)
|
2015-03-25 00:31:09 +00:00
|
|
|
endforeach()
|
|
|
|
|
2016-11-29 02:57:41 +00:00
|
|
|
add_custom_command(OUTPUT ${EXECUTABLE_OUTPUT_PATH}/${bundle}.dmg
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E remove ${EXECUTABLE_OUTPUT_PATH}/${bundle}.dmg
|
|
|
|
COMMAND hdiutil create -srcfolder ${EXECUTABLE_OUTPUT_PATH}/${bundle}.app
|
|
|
|
${EXECUTABLE_OUTPUT_PATH}/${bundle}.dmg
|
2015-03-25 00:31:09 +00:00
|
|
|
DEPENDS $<TARGET_FILE:${bundle}>
|
2016-02-19 10:15:59 +00:00
|
|
|
COMMENT "Building ${bundle}.dmg"
|
|
|
|
VERBATIM)
|
2015-03-25 00:31:09 +00:00
|
|
|
add_custom_target(${bundle}-dmg ALL
|
2016-11-29 02:57:41 +00:00
|
|
|
DEPENDS ${EXECUTABLE_OUTPUT_PATH}/${bundle}.dmg)
|
2016-02-17 06:22:34 +00:00
|
|
|
endif()
|