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)
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
"Whether the test suite will be built and run")
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)
else()
# On Linux and BSDs we're a good citizen and link to system libraries.
find_package(Backtrace)
find_package(PkgConfig REQUIRED)
find_package(ZLIB REQUIRED)

View File

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