Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No gui compilation #144

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ if(MOLOVOL_OSX_FAT_FILE)
endif()

# wxWidgets
set(wxWidgets_USE_STATIC=ON)
find_package(wxWidgets REQUIRED core base OPTIONAL_COMPONENTS net)
include(${wxWidgets_USE_FILE})
if(MOLOVOL_BUILD_GUI)
set(wxWidgets_USE_STATIC=ON)
find_package(wxWidgets REQUIRED core base OPTIONAL_COMPONENTS net)
include(${wxWidgets_USE_FILE})
endif()

#find_package(OpenMP)

Expand Down Expand Up @@ -76,7 +78,9 @@ add_executable(${EXE_NAME} ${SOURCES} ${OSX_RESOURCE_FILES})
# XCode, app bundle and libtiff
include(MacSpecific)

target_link_libraries(${EXE_NAME} ${wxWidgets_LIBRARIES})
if(MOLOVOL_BUILD_GUI)
target_link_libraries(${EXE_NAME} ${wxWidgets_LIBRARIES})
endif()
# Add custom flag
if(MOLOVOL_ABS_RESOURCE_PATH)
target_compile_definitions(${EXE_NAME} PUBLIC -DABS_PATH)
Expand Down
51 changes: 28 additions & 23 deletions cmake/DebInstall.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@

include(GNUInstallDirs)

# Compress changelog
# Compress changelog and man pages (needed for both GUI and non-GUI)
set(DEB_CHANGELOG_COMPRESSED "${CMAKE_CURRENT_BINARY_DIR}/changelog.gz")
set(DEB_MAN_COMPRESSED "${CMAKE_CURRENT_BINARY_DIR}/molovol.1.gz")
set(HICOLOR_DIR "${CMAKE_CURRENT_BINARY_DIR}/hicolor")

add_custom_command(
OUTPUT ${DEB_CHANGELOG_COMPRESSED} ${DEB_MAN_COMPRESSED}
Expand All @@ -15,39 +13,46 @@ add_custom_command(
COMMENT "Compressing changelog and manual file"
)

add_custom_command(
OUTPUT ${HICOLOR_DIR}
COMMAND bash ${DEB_RES_DIR}/shell/resize_icon ${DEB_ICON} ./
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${DEB_ICON}
COMMENT "Resizing icon to supported sizes"
)

add_custom_target(compress ALL DEPENDS ${DEB_CHANGELOG_COMPRESSED} ${DEB_MAN_COMPRESSED})

add_custom_target(resize_icon ALL DEPENDS ${HICOLOR_DIR})

#
execute_process(COMMAND dpkg --print-architecture COMMAND tr -d '\n' OUTPUT_VARIABLE LINUX_ARCHITECTURE)
if(MOLOVOL_BUILD_GUI)
# GUI-specific icon processing
set(HICOLOR_DIR "${CMAKE_CURRENT_BINARY_DIR}/hicolor")

add_custom_command(
OUTPUT ${HICOLOR_DIR}
COMMAND bash ${DEB_RES_DIR}/shell/resize_icon ${DEB_ICON} ./
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${DEB_ICON}
COMMENT "Resizing icon to supported sizes"
)

add_custom_target(resize_icon ALL DEPENDS ${HICOLOR_DIR})
endif()

# Set directory permissions to 0755
# Must come before install commands
set(
CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)

# Install commands so that these files get added to the deb file
# Install commands for both GUI and non-GUI
install(TARGETS ${EXE_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${ELEM_FILE} ${SPACEGROUP_FILE}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${EXE_NAME})
install(FILES ${DEB_COPYRIGHT_FILE} ${DEB_CHANGELOG_COMPRESSED}
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/${EXE_NAME})
install(FILES ${DEB_DESKTOP_FILE}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
install(FILES ${DEB_MAN_COMPRESSED} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
install(FILES ${DEB_ICON} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pixmaps)
install(DIRECTORY ${HICOLOR_DIR} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons)

install(FILES ${DEB_MAN_COMPRESSED}
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)

# GUI-specific install commands
if(MOLOVOL_BUILD_GUI)
install(FILES ${DEB_DESKTOP_FILE}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/applications)
install(FILES ${DEB_ICON}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pixmaps)
install(DIRECTORY ${HICOLOR_DIR}
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/icons)
endif()
35 changes: 18 additions & 17 deletions cmake/MacSpecific.cmake
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
if(MOLOVOL_BUILD_GUI)
# XCode compatibility
set_target_properties(${EXE_NAME} PROPERTIES
XCODE_GENERATE_SCHEME TRUE
XCODE_SCHEME_WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)

# XCode compatibility
set_target_properties(${EXE_NAME} PROPERTIES
XCODE_GENERATE_SCHEME TRUE
XCODE_SCHEME_WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
# macOS Bundle
set_target_properties(${EXE_NAME} PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME}
MACOSX_BUNDLE_EXECUTABLE_NAME ${PROJECT_NAME}
MACOSX_BUNDLE_BUNDLE_VERSION ${CMAKE_PROJECT_VERSION}
MACOSX_BUNDLE_ICON_FILE icon
)

# macOS Bundle
set_target_properties(${EXE_NAME} PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME}
MACOSX_BUNDLE_EXECUTABLE_NAME ${PROJECT_NAME}
MACOSX_BUNDLE_BUNDLE_VERSION ${CMAKE_PROJECT_VERSION}
MACOSX_BUNDLE_ICON_FILE icon
)

# Library shenanigans
if(APPLE)
string(REPLACE "-ltiff" "/usr/local/opt/libtiff/lib/libtiff.a" wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
endif()
# Library shenanigans for wxWidgets
if(APPLE)
string(REPLACE "-ltiff" "/usr/local/opt/libtiff/lib/libtiff.a" wxWidgets_LIBRARIES "${wxWidgets_LIBRARIES}")
endif()
endif()
6 changes: 6 additions & 0 deletions cmake/Options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,9 @@ if (CMAKE_MACOSX_BUNDLE AND NOT MOLOVOL_ABS_RESOURCE_PATH)
message(WARNING "The executable inside a macOS application bundle is always compiled with MOLOVOL_ABS_RESOURCE_PATH enabled")
set(MOLOVOL_ABS_RESOURCE_PATH TRUE)
endif()

option(
MOLOVOL_BUILD_GUI
"Build MoloVol with GUI support (requires wxWidgets)"
ON
)
47 changes: 28 additions & 19 deletions cmake/Resources.cmake
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
# RESOURCE FILES
# Universal resource files
# Universal resource files (needed for both GUI and non-GUI)
set(ELEM_FILE "${CMAKE_CURRENT_SOURCE_DIR}/inputfile/elements.txt")
set(SPACEGROUP_FILE "${CMAKE_CURRENT_SOURCE_DIR}/inputfile/space_groups.txt")
set(LICENSE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(README_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md")

# Resource files for macOS Bundle
set(OSX_RES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/res/macOS")
set(OSX_ICON_FILE "${OSX_RES_DIR}/icon.icns")
set(OSX_LICENSE_RTF "${OSX_RES_DIR}/LICENSE.rtf")
set(OSX_DMG_BACKGROUND "${OSX_RES_DIR}/background.png")
set(OSX_DMG_DSSTORE "${OSX_RES_DIR}/DS_Store/.DS_Store")
set_source_files_properties(${OSX_ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set_source_files_properties(${ELEM_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set_source_files_properties(${SPACEGROUP_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set(OSX_RESOURCE_FILES ${OSX_ICON_FILE} ${ELEM_FILE} ${SPACEGROUP_FILE})
if(MOLOVOL_BUILD_GUI)
# Resource files for macOS Bundle (GUI only)
set(OSX_RES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/res/macOS")
set(OSX_ICON_FILE "${OSX_RES_DIR}/icon.icns")
set(OSX_LICENSE_RTF "${OSX_RES_DIR}/LICENSE.rtf")
set(OSX_DMG_BACKGROUND "${OSX_RES_DIR}/background.png")
set(OSX_DMG_DSSTORE "${OSX_RES_DIR}/DS_Store/.DS_Store")

if(APPLE)
set_source_files_properties(${OSX_ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set_source_files_properties(${ELEM_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set_source_files_properties(${SPACEGROUP_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
set(OSX_RESOURCE_FILES ${OSX_ICON_FILE} ${ELEM_FILE} ${SPACEGROUP_FILE})
endif()

# Resource files for Debian package
set(DEB_RES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/res/linux")
set(DEB_COPYRIGHT_FILE "${DEB_RES_DIR}/copyright")
set(DEB_CHANGELOG_FILE "${DEB_RES_DIR}/changelog")
file(STRINGS ${DEB_RES_DIR}/MoloVol.desktop DEB_DESKTOP_FILE)
set(DEB_DESKTOP_FILE ${DEB_RES_DIR}/MoloVol.desktop)
set(DEB_MAN_FILE ${DEB_RES_DIR}/molovol.1)
set(DEB_ICON ${DEB_RES_DIR}/molovol.png)
# GUI-specific Debian package resources
set(DEB_RES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/res/linux")
set(DEB_DESKTOP_FILE ${DEB_RES_DIR}/MoloVol.desktop)
set(DEB_ICON ${DEB_RES_DIR}/molovol.png)
endif()

# Debian package resources needed for both GUI and non-GUI
if(UNIX AND NOT APPLE)
set(DEB_RES_DIR "${CMAKE_CURRENT_SOURCE_DIR}/res/linux")
set(DEB_COPYRIGHT_FILE "${DEB_RES_DIR}/copyright")
set(DEB_CHANGELOG_FILE "${DEB_RES_DIR}/changelog")
set(DEB_MAN_FILE "${DEB_RES_DIR}/molovol.1")
endif()
31 changes: 22 additions & 9 deletions cmake/Sources.cmake
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@

# List of source files
set(SOURCES
# Base sources (non-GUI)
set(BASE_SOURCES
src/atom.cpp
src/atomtree.cpp
src/base_guicontrol.cpp
src/base_cmdline.cpp
src/base_constr.cpp
src/base_event.cpp
src/base_guicontrol.cpp
src/base_init.cpp
src/cavity.cpp
src/controller.cpp
src/crystallographer.cpp
src/griddata.cpp
src/importmanager.cpp
Expand All @@ -22,4 +15,24 @@ set(SOURCES
src/special_chars.cpp
src/vector.cpp
src/voxel.cpp
src/controller.cpp
)

# GUI-specific sources
set(GUI_SOURCES
src/base_guicontrol.cpp
src/base_constr.cpp
src/base_event.cpp
src/base_init.cpp
)

set(CLI_SOURCES
src/base_cmdline.cpp
)

if(MOLOVOL_BUILD_GUI)
set(SOURCES ${BASE_SOURCES} ${GUI_SOURCES})
else()
set(SOURCES ${BASE_SOURCES} ${CLI_SOURCES})
endif()

32 changes: 17 additions & 15 deletions container/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# builds molovol and installs the webapp
FROM bsvogler/wxwidgets
# hack to create a headless x server, cmake for building
RUN apt update && apt upgrade -y
RUN apt-get install xvfb cmake -y
# does not work when set in dockerfile?
ENV DISPLAY=:1.0

FROM alpine:latest
RUN apk add --no-cache \
cmake \
make \
gcc \
g++ \
musl-dev
# compile molovol, for some reason some less important files like the readme are needed for cmake
WORKDIR /build
COPY cmake/ cmake/
Expand All @@ -16,24 +16,26 @@ COPY include/ include/
COPY LICENSE ./
COPY README.md ./
COPY inputfile/ inputfile/
RUN cmake . -DCMAKE_BUILD_TYPE=RELEASE -DMOLOVOL_ABS_RESOURCE_PATH=ON && make
RUN cmake . -DCMAKE_BUILD_TYPE=RELEASE -DMOLOVOL_ABS_RESOURCE_PATH=ON -DMOLOVOL_BUILD_GUI=OFF && make
RUN apk add --no-cache \
file \
dpkg
RUN cpack -G DEB && dpkg -i MoloVol_*.deb
WORKDIR /

# add flask webserver
#RUN apt install software-properties-common -y
RUN apt install python3.11 curl -y && apt-get clean && rm -rf /var/lib/apt/lists/*
RUN apk add --no-cache python3 py3-pip curl

# install poetry
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/usr/local/ python3 - --version 1.6.1
RUN curl -sSL https://install.python-poetry.org | POETRY_HOME=/usr/local/ python3 - --version 1.8.1
RUN poetry config virtualenvs.create false
RUN poetry config virtualenvs.options.system-site-packages true
ENV PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.12/site-packages/

# install dependencies
COPY webserver/ ./
RUN poetry install --no-root --only main

WORKDIR /

COPY launch_headless.sh /launch_headless.sh
RUN chmod +x launch_headless.sh
ENV FLASK_APP=/webserver/app.py
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
CMD [ "python3", "-m" , "flask", "run", "--host=0.0.0.0"]
9 changes: 0 additions & 9 deletions container/alpine_wip.Dockerfile

This file was deleted.

32 changes: 0 additions & 32 deletions container/headless.Dockerfile

This file was deleted.

Loading