CMake: add an ENABLE_CLI flag.

pull/339/head
whitequark 2018-07-18 11:49:06 +00:00
parent 22a9705a21
commit efc3da4579
2 changed files with 20 additions and 15 deletions

View File

@ -35,7 +35,9 @@ 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 set(ENABLE_GUI ON CACHE BOOL
"Whether the graphical interface is enabled (command line interface always is)") "Whether the graphical interface is enabled")
set(ENABLE_CLI ON CACHE BOOL
"Whether the command line interface is enabled")
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
@ -157,7 +159,6 @@ if(WIN32 OR APPLE)
list(APPEND CAIRO_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/extlib/cairo/src) list(APPEND CAIRO_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/extlib/cairo/src)
else() else()
# On Linux and BSDs we're a good citizen and link to system libraries. # On Linux and BSDs we're a good citizen and link to system libraries.
find_package(Backtrace) find_package(Backtrace)
find_package(PkgConfig REQUIRED) find_package(PkgConfig REQUIRED)
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)

View File

@ -359,20 +359,22 @@ target_compile_options(solvespace-headless
# solvespace command-line executable # solvespace command-line executable
add_executable(solvespace-cli if(ENABLE_CLI)
platform/entrycli.cpp add_executable(solvespace-cli
$<TARGET_PROPERTY:resources,EXTRA_SOURCES>) platform/entrycli.cpp
$<TARGET_PROPERTY:resources,EXTRA_SOURCES>)
target_link_libraries(solvespace-cli target_link_libraries(solvespace-cli
solvespace-core solvespace-core
solvespace-headless) solvespace-headless)
add_dependencies(solvespace-cli add_dependencies(solvespace-cli
resources) resources)
if(MSVC) if(MSVC)
set_target_properties(solvespace-cli PROPERTIES set_target_properties(solvespace-cli PROPERTIES
LINK_FLAGS "/INCREMENTAL:NO /OPT:REF") LINK_FLAGS "/INCREMENTAL:NO /OPT:REF")
endif()
endif() endif()
# solvespace unix package # solvespace unix package
@ -382,8 +384,10 @@ if(NOT (WIN32 OR APPLE))
install(TARGETS solvespace install(TARGETS solvespace
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif() endif()
install(TARGETS solvespace-cli if(ENABLE_CLI)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) install(TARGETS solvespace-cli
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
endif() endif()
# solvespace macOS package # solvespace macOS package