CMake: allow building the CLI without the GUI.
parent
9253e5f229
commit
e127b28a2d
|
@ -4,7 +4,9 @@ if echo $TRAVIS_TAG | grep ^v; then BUILD_TYPE=RelWithDebInfo; else BUILD_TYPE=D
|
|||
|
||||
mkdir build
|
||||
cd build
|
||||
# We build without the GUI until Travis updates to an Ubuntu version with GTK 3.22.
|
||||
cmake .. -DCMAKE_C_COMPILER=clang-3.9 -DCMAKE_CXX_COMPILER=clang++-3.9 \
|
||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
|
||||
-DENABLE_GUI=OFF \
|
||||
-DENABLE_SANITIZERS=ON
|
||||
make VERBOSE=1
|
||||
|
|
|
@ -34,6 +34,8 @@ set(solvespace_VERSION_MAJOR 3)
|
|||
set(solvespace_VERSION_MINOR 0)
|
||||
string(SUBSTRING "${GIT_COMMIT_HASH}" 0 8 solvespace_GIT_HASH)
|
||||
|
||||
set(ENABLE_GUI ON CACHE BOOL
|
||||
"Whether the graphical interface is enabled (command line interface always is)")
|
||||
set(ENABLE_TESTS ON CACHE BOOL
|
||||
"Whether the test suite will be built and run")
|
||||
set(ENABLE_COVERAGE OFF CACHE BOOL
|
||||
|
@ -120,22 +122,6 @@ if(WIN32)
|
|||
PNG_PNG_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/libpng)
|
||||
list(APPEND PNG_PNG_INCLUDE_DIR ${CMAKE_BINARY_DIR}/extlib/libpng)
|
||||
|
||||
if(OPENGL STREQUAL "2")
|
||||
message(STATUS "Using in-tree ANGLE")
|
||||
set(ANGLE_STATIC ON CACHE INTERNAL "")
|
||||
set(ANGLE_ENABLE_D3D9 ON CACHE INTERNAL "")
|
||||
set(ANGLE_ENABLE_D3D11 ON CACHE INTERNAL "")
|
||||
set(ANGLE_ENABLE_OPENGL OFF CACHE INTERNAL "")
|
||||
set(ANGLE_ENABLE_ESSL OFF CACHE INTERNAL "")
|
||||
set(ANGLE_ENABLE_GLSL OFF CACHE INTERNAL "")
|
||||
set(ANGLE_ENABLE_HLSL ON CACHE INTERNAL "")
|
||||
add_vendored_subdirectory(extlib/angle)
|
||||
set(OPENGL_LIBRARIES EGL GLESv2)
|
||||
set(OPENGL_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/angle/include)
|
||||
else()
|
||||
find_package(OpenGL REQUIRED)
|
||||
endif()
|
||||
|
||||
message(STATUS "Using in-tree pixman")
|
||||
add_vendored_subdirectory(extlib/pixman)
|
||||
set(PIXMAN_FOUND YES)
|
||||
|
@ -150,13 +136,31 @@ if(WIN32)
|
|||
set(CAIRO_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extlib/cairo/src)
|
||||
list(APPEND CAIRO_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/extlib/cairo/src)
|
||||
|
||||
if(NOT MINGW)
|
||||
message(STATUS "Using prebuilt SpaceWare")
|
||||
set(SPACEWARE_FOUND TRUE)
|
||||
set(SPACEWARE_INCLUDE_DIR
|
||||
"${CMAKE_SOURCE_DIR}/extlib/si")
|
||||
set(SPACEWARE_LIBRARIES
|
||||
"${CMAKE_SOURCE_DIR}/extlib/si/siapp.lib")
|
||||
if(ENABLE_GUI)
|
||||
if(OPENGL STREQUAL "2")
|
||||
message(STATUS "Using in-tree ANGLE")
|
||||
set(ANGLE_STATIC ON CACHE INTERNAL "")
|
||||
set(ANGLE_ENABLE_D3D9 ON CACHE INTERNAL "")
|
||||
set(ANGLE_ENABLE_D3D11 ON CACHE INTERNAL "")
|
||||
set(ANGLE_ENABLE_OPENGL OFF CACHE INTERNAL "")
|
||||
set(ANGLE_ENABLE_ESSL OFF CACHE INTERNAL "")
|
||||
set(ANGLE_ENABLE_GLSL OFF CACHE INTERNAL "")
|
||||
set(ANGLE_ENABLE_HLSL ON CACHE INTERNAL "")
|
||||
add_vendored_subdirectory(extlib/angle)
|
||||
set(OPENGL_LIBRARIES EGL GLESv2)
|
||||
set(OPENGL_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/angle/include)
|
||||
else()
|
||||
find_package(OpenGL REQUIRED)
|
||||
endif()
|
||||
|
||||
if(NOT MINGW)
|
||||
message(STATUS "Using prebuilt SpaceWare")
|
||||
set(SPACEWARE_FOUND TRUE)
|
||||
set(SPACEWARE_INCLUDE_DIR
|
||||
"${CMAKE_SOURCE_DIR}/extlib/si")
|
||||
set(SPACEWARE_LIBRARIES
|
||||
"${CMAKE_SOURCE_DIR}/extlib/si/siapp.lib")
|
||||
endif()
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
set(CMAKE_FIND_FRAMEWORK LAST)
|
||||
|
@ -164,12 +168,14 @@ elseif(APPLE)
|
|||
find_package(ZLIB REQUIRED)
|
||||
find_package(PNG REQUIRED)
|
||||
find_package(Freetype REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
find_library(CAIRO_LIBRARIES cairo REQUIRED)
|
||||
find_path(CAIRO_INCLUDE_DIRS cairo.h PATH_SUFFIXES cairo)
|
||||
|
||||
find_library(APPKIT_LIBRARY AppKit REQUIRED)
|
||||
if(ENABLE_GUI)
|
||||
find_package(OpenGL REQUIRED)
|
||||
find_library(APPKIT_LIBRARY AppKit REQUIRED)
|
||||
endif()
|
||||
else() # Linux and compatible systems
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
|
@ -179,12 +185,14 @@ else() # Linux and compatible systems
|
|||
find_package(ZLIB REQUIRED)
|
||||
find_package(PNG REQUIRED)
|
||||
find_package(Freetype REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
pkg_check_modules(CAIRO REQUIRED cairo)
|
||||
pkg_check_modules(FONTCONFIG REQUIRED fontconfig)
|
||||
pkg_check_modules(JSONC REQUIRED json-c)
|
||||
pkg_check_modules(GTKMM REQUIRED gtkmm-3.0>=3.22 pangomm-1.4 x11)
|
||||
|
||||
if(ENABLE_GUI)
|
||||
find_package(OpenGL REQUIRED)
|
||||
pkg_check_modules(FONTCONFIG REQUIRED fontconfig)
|
||||
pkg_check_modules(JSONC REQUIRED json-c)
|
||||
pkg_check_modules(GTKMM REQUIRED gtkmm-3.0>=3.22 pangomm-1.4 x11)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_COVERAGE)
|
||||
|
|
24
README.md
24
README.md
|
@ -25,12 +25,14 @@ Building on Linux
|
|||
|
||||
### Building for Linux
|
||||
|
||||
You will need CMake, zlib, json-c, libpng, cairo, freetype, fontconfig, gtkmm 3.0, pangomm 1.4,
|
||||
OpenGL and OpenGL GLU, and optionally, the Space Navigator client library.
|
||||
You will need CMake, zlib, libpng, cairo, freetype. To build the GUI, you will need
|
||||
fontconfig, gtkmm 3.0, pangomm 1.4, OpenGL and OpenGL GLU, and optionally,
|
||||
the Space Navigator client library
|
||||
.
|
||||
On a Debian derivative (e.g. Ubuntu) these can be installed with:
|
||||
|
||||
apt-get install cmake libjson-c-dev libpng-dev libcairo2-dev libfreetype6-dev \
|
||||
libfontconfig1-dev libgtkmm-3.0-dev libpangomm-1.4-dev \
|
||||
apt-get install cmake zlib1-dev libpng-dev libcairo2-dev libfreetype6-dev
|
||||
apt-get install libjson-c-dev libfontconfig1-dev libgtkmm-3.0-dev libpangomm-1.4-dev \
|
||||
libgl-dev libglu-dev libspnav-dev
|
||||
|
||||
Before building, check out the necessary submodules:
|
||||
|
@ -45,7 +47,9 @@ After that, build SolveSpace as following:
|
|||
make
|
||||
sudo make install
|
||||
|
||||
The application is built as `build/bin/solvespace`.
|
||||
The graphical interface is built as `build/bin/solvespace`, and the command-line interface
|
||||
is built as `build/bin/solvespace-cli`. It is possible to build only the command-line interface
|
||||
by passing the `-DENABLE_GUI=OFF` flag to the cmake invocation.
|
||||
|
||||
### Building for Windows
|
||||
|
||||
|
@ -74,7 +78,8 @@ Or, build 64-bit SolveSpace as following:
|
|||
-DENABLE_TESTS=OFF
|
||||
make
|
||||
|
||||
The application is built as `build/bin/solvespace.exe`.
|
||||
The graphical interface is built as `build/bin/solvespace.exe`, and the command-line interface
|
||||
is built as `build/bin/solvespace-cli.exe`.
|
||||
|
||||
Space Navigator support will not be available.
|
||||
|
||||
|
@ -100,15 +105,16 @@ After that, build SolveSpace as following:
|
|||
cmake .. -DENABLE_TESTS=OFF
|
||||
make
|
||||
|
||||
The application is built in `build/bin/solvespace.app`, and
|
||||
the executable file is `build/bin/solvespace.app/Contents/MacOS/solvespace`.
|
||||
The application is built in `build/bin/solvespace.app`, the graphical interface executable
|
||||
is `build/bin/solvespace.app/Contents/MacOS/solvespace`, and the command-line interface executable
|
||||
is `build/bin/solvespace.app/Contents/MacOS/solvespace-cli`.
|
||||
|
||||
[homebrew]: http://brew.sh/
|
||||
|
||||
Building on Windows
|
||||
-------------------
|
||||
|
||||
You will need [git][gitwin], [cmake][cmakewin] and Visual C++.
|
||||
You will need [git][gitwin], [cmake][cmakewin] and Visual C++.
|
||||
|
||||
### Building with Visual Studio IDE
|
||||
|
||||
|
|
|
@ -208,23 +208,25 @@ target_compile_options(solvespace-core
|
|||
|
||||
# solvespace graphical executable
|
||||
|
||||
add_executable(solvespace WIN32 MACOSX_BUNDLE
|
||||
${solvespace_core_gl_SOURCES}
|
||||
${platform_SOURCES}
|
||||
$<TARGET_PROPERTY:resources,EXTRA_SOURCES>)
|
||||
if(ENABLE_GUI)
|
||||
add_executable(solvespace WIN32 MACOSX_BUNDLE
|
||||
${solvespace_core_gl_SOURCES}
|
||||
${platform_SOURCES}
|
||||
$<TARGET_PROPERTY:resources,EXTRA_SOURCES>)
|
||||
|
||||
add_dependencies(solvespace
|
||||
resources)
|
||||
add_dependencies(solvespace
|
||||
resources)
|
||||
|
||||
target_link_libraries(solvespace
|
||||
solvespace-core
|
||||
${OPENGL_LIBRARIES}
|
||||
${platform_LIBRARIES}
|
||||
${COVERAGE_LIBRARY})
|
||||
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")
|
||||
if(MSVC)
|
||||
set_target_properties(solvespace PROPERTIES
|
||||
LINK_FLAGS "/MANIFEST:NO /SAFESEH:NO /INCREMENTAL:NO /OPT:REF")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# solvespace headless library
|
||||
|
@ -271,7 +273,11 @@ endif()
|
|||
# solvespace unix package
|
||||
|
||||
if(NOT (WIN32 OR APPLE))
|
||||
install(TARGETS solvespace solvespace-cli
|
||||
if(ENABLE_GUI)
|
||||
install(TARGETS solvespace
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
install(TARGETS solvespace-cli
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
|
||||
endif()
|
||||
|
||||
|
|
Loading…
Reference in New Issue