Skip to content

Commit

Permalink
Add flag to compile CLI-only (fix aseprite#1279)
Browse files Browse the repository at this point in the history
New cmake flag -DENABLE_UI=OFF can be used to turn off the GUI
and compile a CLI-only version of Aseprite.

Requested here too:
https://community.aseprite.org/t/1351
  • Loading branch information
dacap committed May 7, 2018
1 parent c221685 commit 139c5aa
Show file tree
Hide file tree
Showing 43 changed files with 845 additions and 550 deletions.
7 changes: 6 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ compiler:
- clang
- gcc

env:
matrix:
- ENABLE_UI=OFF
- ENABLE_UI=ON

before_install:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update -qq
Expand All @@ -14,7 +19,7 @@ before_install:
before_script:
- mkdir build
- cd build
- cmake .. -DENABLE_TESTS=ON
- cmake .. -DENABLE_TESTS=ON -DENABLE_UI=$ENABLE_UI

script:
- "make"
Expand Down
20 changes: 15 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,26 @@ option(ENABLE_BENCHMARKS "Compile benchmarks" off)
option(ENABLE_TRIAL_MODE "Compile the trial version" off)
option(ENABLE_STEAM "Compile with Steam library" off)
option(ENABLE_DEVMODE "Compile vesion for developers" off)
option(ENABLE_UI "Compile UI (turn off to compile CLI-only version)" on)
option(FULLSCREEN_PLATFORM "Enable fullscreen by default" off)
set(CUSTOM_WEBSITE_URL "" CACHE STRING "Enable custom local webserver to check updates")

if(APPLE)
# On OS X Allegro isn't supported anymore
if(NOT ENABLE_UI)
# Without UI, don't use back-ends
set(USE_ALLEG4_BACKEND off)
set(USE_SKIA_BACKEND on)
set(USE_SKIA_BACKEND off)
set(USE_NONE_BACKEND on)
else()
option(USE_ALLEG4_BACKEND "Use Allegro 4 backend" on)
option(USE_SKIA_BACKEND "Use Skia backend" off)
if(APPLE)
# On OS X Allegro isn't supported anymore
set(USE_ALLEG4_BACKEND off)
set(USE_SKIA_BACKEND on)
set(USE_NONE_BACKEND off)
else()
option(USE_ALLEG4_BACKEND "Use Allegro 4 backend" on)
option(USE_SKIA_BACKEND "Use Skia backend" off)
set(USE_NONE_BACKEND off)
endif()
endif()

# Check valid gtk + libpng combination
Expand Down
41 changes: 28 additions & 13 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,36 @@ if(NOT "${CUSTOM_WEBSITE_URL}" STREQUAL "")
endif()

######################################################################
# Full-version or trial-mode?
# With static libcurl

if(NOT USE_SHARED_CURL AND CURL_STATICLIB)
add_definitions(-DCURL_STATICLIB)
endif()

######################################################################
# Full-version or trial-mode?
# Special versions (full/trial, devmode, UI/CLI, etc.)

if(NOT ENABLE_TRIAL_MODE)
add_definitions(-DENABLE_SAVE -DENABLE_DATA_RECOVERY)
add_definitions(-DENABLE_SAVE)
else()
add_definitions(-DENABLE_TRIAL_MODE)
endif()

######################################################################
# Special developer mode

if(ENABLE_DEVMODE)
add_definitions(-DENABLE_DEVMODE)
endif()

if(ENABLE_UI)
add_definitions(-DENABLE_UI)
endif()

if(ENABLE_UI AND NOT ENABLE_TRIAL_MODE)
set(ENABLE_DATA_RECOVERY on)
add_definitions(-DENABLE_DATA_RECOVERY)
else()
set(ENABLE_DATA_RECOVERY off)
endif()

######################################################################
# Aseprite Libraries (in preferred order to be built)

Expand Down Expand Up @@ -170,16 +178,23 @@ if(WIN32)
main/settings.manifest)
endif()

add_executable(aseprite WIN32
main/main.cpp
${win32_resources})
add_executable(aseprite main/main.cpp ${win32_resources})
if(WIN32 AND ENABLE_UI)
set_target_properties(aseprite PROPERTIES WIN32_EXECUTABLE true)
endif()
target_link_libraries(aseprite app-lib ${PLATFORM_LIBS})
add_dependencies(aseprite copy_data)

if(MSVC AND USE_SKIA_BACKEND)
# Add support to expand filename wildcards in argc/argv
set_target_properties(aseprite
PROPERTIES LINK_FLAGS "-LINK wsetargv.obj -ENTRY:\"wWinMainCRTStartup\"")
if(MSVC)
if(USE_SKIA_BACKEND)
# Linking with "wsetargv.obj" to add support to expand filename
# wildcards in argc/argv.
set_target_properties(aseprite
PROPERTIES LINK_FLAGS "-LINK wsetargv.obj -ENTRY:\"wWinMainCRTStartup\"")
else()
set_target_properties(aseprite
PROPERTIES LINK_FLAGS "-LINK wsetargv.obj -ENTRY:\"wmainCRTStartup\"")
endif()
endif()

install(TARGETS aseprite
Expand Down
Loading

0 comments on commit 139c5aa

Please sign in to comment.