CMake: allow building the CLI without the GUI.

pull/106/head
whitequark 2017-01-02 22:02:37 +00:00
parent 9253e5f229
commit e127b28a2d
4 changed files with 76 additions and 54 deletions

View File

@ -4,7 +4,9 @@ if echo $TRAVIS_TAG | grep ^v; then BUILD_TYPE=RelWithDebInfo; else BUILD_TYPE=D
mkdir build mkdir build
cd 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 \ cmake .. -DCMAKE_C_COMPILER=clang-3.9 -DCMAKE_CXX_COMPILER=clang++-3.9 \
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \ -DCMAKE_BUILD_TYPE=$BUILD_TYPE \
-DENABLE_GUI=OFF \
-DENABLE_SANITIZERS=ON -DENABLE_SANITIZERS=ON
make VERBOSE=1 make VERBOSE=1

View File

@ -34,6 +34,8 @@ set(solvespace_VERSION_MAJOR 3)
set(solvespace_VERSION_MINOR 0) set(solvespace_VERSION_MINOR 0)
string(SUBSTRING "${GIT_COMMIT_HASH}" 0 8 solvespace_GIT_HASH) 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 set(ENABLE_TESTS ON CACHE BOOL
"Whether the test suite will be built and run") "Whether the test suite will be built and run")
set(ENABLE_COVERAGE OFF CACHE BOOL set(ENABLE_COVERAGE OFF CACHE BOOL
@ -120,6 +122,21 @@ if(WIN32)
PNG_PNG_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/libpng) PNG_PNG_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/extlib/libpng)
list(APPEND PNG_PNG_INCLUDE_DIR ${CMAKE_BINARY_DIR}/extlib/libpng) list(APPEND PNG_PNG_INCLUDE_DIR ${CMAKE_BINARY_DIR}/extlib/libpng)
message(STATUS "Using in-tree pixman")
add_vendored_subdirectory(extlib/pixman)
set(PIXMAN_FOUND YES)
set(PIXMAN_LIBRARY pixman)
set(PIXMAN_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extlib/pixman/pixman)
list(APPEND PIXMAN_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/extlib/pixman/pixman)
message(STATUS "Using in-tree cairo")
add_vendored_subdirectory(extlib/cairo)
set(CAIRO_FOUND YES)
set(CAIRO_LIBRARIES cairo)
set(CAIRO_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extlib/cairo/src)
list(APPEND CAIRO_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/extlib/cairo/src)
if(ENABLE_GUI)
if(OPENGL STREQUAL "2") if(OPENGL STREQUAL "2")
message(STATUS "Using in-tree ANGLE") message(STATUS "Using in-tree ANGLE")
set(ANGLE_STATIC ON CACHE INTERNAL "") set(ANGLE_STATIC ON CACHE INTERNAL "")
@ -136,20 +153,6 @@ if(WIN32)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
endif() endif()
message(STATUS "Using in-tree pixman")
add_vendored_subdirectory(extlib/pixman)
set(PIXMAN_FOUND YES)
set(PIXMAN_LIBRARY pixman)
set(PIXMAN_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extlib/pixman/pixman)
list(APPEND PIXMAN_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/extlib/pixman/pixman)
message(STATUS "Using in-tree cairo")
add_vendored_subdirectory(extlib/cairo)
set(CAIRO_FOUND YES)
set(CAIRO_LIBRARIES cairo)
set(CAIRO_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extlib/cairo/src)
list(APPEND CAIRO_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/extlib/cairo/src)
if(NOT MINGW) if(NOT MINGW)
message(STATUS "Using prebuilt SpaceWare") message(STATUS "Using prebuilt SpaceWare")
set(SPACEWARE_FOUND TRUE) set(SPACEWARE_FOUND TRUE)
@ -158,18 +161,21 @@ if(WIN32)
set(SPACEWARE_LIBRARIES set(SPACEWARE_LIBRARIES
"${CMAKE_SOURCE_DIR}/extlib/si/siapp.lib") "${CMAKE_SOURCE_DIR}/extlib/si/siapp.lib")
endif() endif()
endif()
elseif(APPLE) elseif(APPLE)
set(CMAKE_FIND_FRAMEWORK LAST) set(CMAKE_FIND_FRAMEWORK LAST)
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED) find_package(PNG REQUIRED)
find_package(Freetype REQUIRED) find_package(Freetype REQUIRED)
find_package(OpenGL REQUIRED)
find_library(CAIRO_LIBRARIES cairo REQUIRED) find_library(CAIRO_LIBRARIES cairo REQUIRED)
find_path(CAIRO_INCLUDE_DIRS cairo.h PATH_SUFFIXES cairo) find_path(CAIRO_INCLUDE_DIRS cairo.h PATH_SUFFIXES cairo)
if(ENABLE_GUI)
find_package(OpenGL REQUIRED)
find_library(APPKIT_LIBRARY AppKit REQUIRED) find_library(APPKIT_LIBRARY AppKit REQUIRED)
endif()
else() # Linux and compatible systems else() # Linux and compatible systems
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
@ -179,12 +185,14 @@ else() # Linux and compatible systems
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED) find_package(PNG REQUIRED)
find_package(Freetype REQUIRED) find_package(Freetype REQUIRED)
find_package(OpenGL REQUIRED)
pkg_check_modules(CAIRO REQUIRED cairo) pkg_check_modules(CAIRO REQUIRED cairo)
if(ENABLE_GUI)
find_package(OpenGL REQUIRED)
pkg_check_modules(FONTCONFIG REQUIRED fontconfig) pkg_check_modules(FONTCONFIG REQUIRED fontconfig)
pkg_check_modules(JSONC REQUIRED json-c) pkg_check_modules(JSONC REQUIRED json-c)
pkg_check_modules(GTKMM REQUIRED gtkmm-3.0>=3.22 pangomm-1.4 x11) pkg_check_modules(GTKMM REQUIRED gtkmm-3.0>=3.22 pangomm-1.4 x11)
endif()
endif() endif()
if(ENABLE_COVERAGE) if(ENABLE_COVERAGE)

View File

@ -25,12 +25,14 @@ Building on Linux
### Building for Linux ### Building for Linux
You will need CMake, zlib, json-c, libpng, cairo, freetype, fontconfig, gtkmm 3.0, pangomm 1.4, You will need CMake, zlib, libpng, cairo, freetype. To build the GUI, you will need
OpenGL and OpenGL GLU, and optionally, the Space Navigator client library. 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: 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 \ apt-get install cmake zlib1-dev libpng-dev libcairo2-dev libfreetype6-dev
libfontconfig1-dev libgtkmm-3.0-dev libpangomm-1.4-dev \ apt-get install libjson-c-dev libfontconfig1-dev libgtkmm-3.0-dev libpangomm-1.4-dev \
libgl-dev libglu-dev libspnav-dev libgl-dev libglu-dev libspnav-dev
Before building, check out the necessary submodules: Before building, check out the necessary submodules:
@ -45,7 +47,9 @@ After that, build SolveSpace as following:
make make
sudo make install 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 ### Building for Windows
@ -74,7 +78,8 @@ Or, build 64-bit SolveSpace as following:
-DENABLE_TESTS=OFF -DENABLE_TESTS=OFF
make 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. Space Navigator support will not be available.
@ -100,8 +105,9 @@ After that, build SolveSpace as following:
cmake .. -DENABLE_TESTS=OFF cmake .. -DENABLE_TESTS=OFF
make make
The application is built in `build/bin/solvespace.app`, and The application is built in `build/bin/solvespace.app`, the graphical interface executable
the executable file is `build/bin/solvespace.app/Contents/MacOS/solvespace`. 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/ [homebrew]: http://brew.sh/

View File

@ -208,23 +208,25 @@ target_compile_options(solvespace-core
# solvespace graphical executable # solvespace graphical executable
add_executable(solvespace WIN32 MACOSX_BUNDLE if(ENABLE_GUI)
add_executable(solvespace WIN32 MACOSX_BUNDLE
${solvespace_core_gl_SOURCES} ${solvespace_core_gl_SOURCES}
${platform_SOURCES} ${platform_SOURCES}
$<TARGET_PROPERTY:resources,EXTRA_SOURCES>) $<TARGET_PROPERTY:resources,EXTRA_SOURCES>)
add_dependencies(solvespace add_dependencies(solvespace
resources) resources)
target_link_libraries(solvespace target_link_libraries(solvespace
solvespace-core solvespace-core
${OPENGL_LIBRARIES} ${OPENGL_LIBRARIES}
${platform_LIBRARIES} ${platform_LIBRARIES}
${COVERAGE_LIBRARY}) ${COVERAGE_LIBRARY})
if(MSVC) if(MSVC)
set_target_properties(solvespace PROPERTIES set_target_properties(solvespace PROPERTIES
LINK_FLAGS "/MANIFEST:NO /SAFESEH:NO /INCREMENTAL:NO /OPT:REF") LINK_FLAGS "/MANIFEST:NO /SAFESEH:NO /INCREMENTAL:NO /OPT:REF")
endif()
endif() endif()
# solvespace headless library # solvespace headless library
@ -271,7 +273,11 @@ endif()
# solvespace unix package # solvespace unix package
if(NOT (WIN32 OR APPLE)) 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}) RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif() endif()