Skip to content

Commit

Permalink
Add proper install target
Browse files Browse the repository at this point in the history
  • Loading branch information
tunabrain committed Feb 3, 2017
1 parent c12d0aa commit 0ac7a73
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 51 deletions.
31 changes: 27 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ if (MSVC)
add_definitions(-D__SSE__)
endif()

add_definitions(-DINSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")

if (USE_AVX)
message(STATUS "Compiling with AVX support")
set(__AVX__ 1)
Expand Down Expand Up @@ -149,6 +151,9 @@ endif()
add_executable(tungsten_server src/tungsten-server/tungsten-server.cpp)
target_link_libraries(tungsten_server ${core_libs} ${socket_libs})

set(executables obj2json json2xml scenemanip hdrmanip denoiser tungsten tungsten_server)
set(data_dirs example-scenes materialtest mc-loader)

find_package(OpenGL)
find_package(Qt5Widgets)
find_package(Qt5OpenGL)
Expand All @@ -160,10 +165,6 @@ if (OPENGL_FOUND AND Qt5Widgets_FOUND)
if (APPLE)
list(APPEND Editor_SOURCES "src/editor/CoreProfileAttributes.mm")
endif()
file(GLOB_RECURSE Data_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "data/*")
foreach (data ${Data_FILES})
configure_file(${data} ${CMAKE_CURRENT_BINARY_DIR}/${data} COPYONLY)
endforeach(data)
add_executable(editor ${Editor_SOURCES} src/editor/resources/Tungsten.rc)
set_target_properties(editor PROPERTIES AUTOMOC TRUE)
qt5_use_modules(editor Widgets OpenGL)
Expand All @@ -173,6 +174,9 @@ if (OPENGL_FOUND AND Qt5Widgets_FOUND)
target_link_libraries(editor ${APPKIT})
endif()
message(STATUS "Building editor")

set(data_dirs ${data_dirs} editor shaders)
set(executables ${executables} editor)
else()
if (NOT Qt5Widgets_FOUND)
message(STATUS "Qt5 not found. Editor will not be built")
Expand All @@ -182,3 +186,22 @@ else()
endif()
endif()

if (WIN32)
set(data_prefix "data")
else()
set(data_prefix "share/tungsten")
endif()

foreach (data_dir ${data_dirs})
install(DIRECTORY data/${data_dir} DESTINATION ${data_prefix})
file(GLOB_RECURSE data_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/data "data/${data_dir}/*")
foreach (data ${data_files})
configure_file(data/${data} ${CMAKE_CURRENT_BINARY_DIR}/${data_prefix}/${data} COPYONLY)
endforeach(data)
endforeach()

if (WIN32)
install(TARGETS ${executables} DESTINATION .)
else()
install(TARGETS ${executables} DESTINATION bin)
endif()
78 changes: 39 additions & 39 deletions data/editor/style/style.qss
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ QScrollBar::handle:horizontal

QScrollBar::add-line:horizontal
{
border-image: url(data/editor/style/rc/right_arrow_disabled.png);
border-image: url(editor/style/rc/right_arrow_disabled.png);
width: 10px;
height: 10px;
subcontrol-position: right;
Expand All @@ -198,7 +198,7 @@ QScrollBar::add-line:horizontal

QScrollBar::sub-line:horizontal
{
border-image: url(data/editor/style/rc/left_arrow_disabled.png);
border-image: url(editor/style/rc/left_arrow_disabled.png);
height: 10px;
width: 10px;
subcontrol-position: left;
Expand All @@ -207,7 +207,7 @@ QScrollBar::sub-line:horizontal

QScrollBar::add-line:horizontal:hover,QScrollBar::add-line:horizontal:on
{
border-image: url(data/editor/style/rc/right_arrow.png);
border-image: url(editor/style/rc/right_arrow.png);
height: 10px;
width: 10px;
subcontrol-position: right;
Expand All @@ -217,7 +217,7 @@ QScrollBar::add-line:horizontal:hover,QScrollBar::add-line:horizontal:on

QScrollBar::sub-line:horizontal:hover, QScrollBar::sub-line:horizontal:on
{
border-image: url(data/editor/style/rc/left_arrow.png);
border-image: url(editor/style/rc/left_arrow.png);
height: 10px;
width: 10px;
subcontrol-position: left;
Expand Down Expand Up @@ -255,7 +255,7 @@ QScrollBar::handle:vertical

QScrollBar::sub-line:vertical
{
border-image: url(data/editor/style/rc/up_arrow_disabled.png);
border-image: url(editor/style/rc/up_arrow_disabled.png);
height: 10px;
width: 10px;
subcontrol-position: top;
Expand All @@ -265,7 +265,7 @@ QScrollBar::sub-line:vertical
QScrollBar::add-line:vertical
{

border-image: url(data/editor/style/rc/down_arrow_disabled.png);
border-image: url(editor/style/rc/down_arrow_disabled.png);
height: 10px;
width: 10px;
subcontrol-position: bottom;
Expand All @@ -275,7 +275,7 @@ QScrollBar::add-line:vertical
QScrollBar::sub-line:vertical:hover,QScrollBar::sub-line:vertical:on
{

border-image: url(data/editor/style/rc/up_arrow.png);
border-image: url(editor/style/rc/up_arrow.png);
height: 10px;
width: 10px;
subcontrol-position: top;
Expand All @@ -285,7 +285,7 @@ QScrollBar::sub-line:vertical:hover,QScrollBar::sub-line:vertical:on

QScrollBar::add-line:vertical:hover, QScrollBar::add-line:vertical:on
{
border-image: url(data/editor/style/rc/down_arrow.png);
border-image: url(editor/style/rc/down_arrow.png);
height: 10px;
width: 10px;
subcontrol-position: bottom;
Expand Down Expand Up @@ -332,7 +332,7 @@ QCheckBox:disabled
}

QSizeGrip {
image: url(data/editor/style/rc/sizegrip.png);
image: url(editor/style/rc/sizegrip.png);
width: 12px;
height: 12px;
}
Expand Down Expand Up @@ -427,7 +427,7 @@ QRadioButton::indicator:hover, QCheckBox::indicator:hover

QCheckBox::indicator:checked, QGroupBox::indicator:checked, QMenu::indicator:non-exclusive:checked
{
image:url(data/editor/style/rc/checkbox.png);
image:url(editor/style/rc/checkbox.png);
}

QCheckBox::indicator:disabled, QRadioButton::indicator:disabled
Expand All @@ -436,7 +436,7 @@ QCheckBox::indicator:disabled, QRadioButton::indicator:disabled
}

QCheckBox::indicator:indeterminate {
image: url(data/editor/style/rc/checkbox_indeterminate.png);
image: url(editor/style/rc/checkbox_indeterminate.png);
}

QFrame
Expand All @@ -456,16 +456,16 @@ QToolBar {
}

QToolBar::handle:horizontal {
image: url(data/editor/style/rc/Hmovetoolbar.png);
image: url(editor/style/rc/Hmovetoolbar.png);
}
QToolBar::handle:vertical {
image: url(data/editor/style/rc/Vmovetoolbar.png);
image: url(editor/style/rc/Vmovetoolbar.png);
}
QToolBar::separator:horizontal {
image: url(data/editor/style/rc/Hsepartoolbar.png);
image: url(editor/style/rc/Hsepartoolbar.png);
}
QToolBar::separator:vertical {
image: url(data/editor/style/rc/Vsepartoolbars.png);
image: url(editor/style/rc/Vsepartoolbars.png);
}

QPushButton
Expand Down Expand Up @@ -548,13 +548,13 @@ QComboBox::drop-down

QComboBox::down-arrow
{
image: url(data/editor/style/rc/down_arrow_disabled.png);
image: url(editor/style/rc/down_arrow_disabled.png);
}

QComboBox::down-arrow:on, QComboBox::down-arrow:hover,
QComboBox::down-arrow:focus
{
image: url(data/editor/style/rc/down_arrow.png);
image: url(editor/style/rc/down_arrow.png);
}

QPushButton:pressed
Expand Down Expand Up @@ -588,25 +588,25 @@ QAbstractSpinBox:down-button
}

QAbstractSpinBox::up-arrow,QAbstractSpinBox::up-arrow:disabled,QAbstractSpinBox::up-arrow:off {
image: url(data/editor/style/rc/up_arrow_disabled.png);
image: url(editor/style/rc/up_arrow_disabled.png);
width: 10px;
height: 10px;
}
QAbstractSpinBox::up-arrow:hover
{
image: url(data/editor/style/rc/up_arrow.png);
image: url(editor/style/rc/up_arrow.png);
}


QAbstractSpinBox::down-arrow,QAbstractSpinBox::down-arrow:disabled,QAbstractSpinBox::down-arrow:off
{
image: url(data/editor/style/rc/down_arrow_disabled.png);
image: url(editor/style/rc/down_arrow_disabled.png);
width: 10px;
height: 10px;
}
QAbstractSpinBox::down-arrow:hover
{
image: url(data/editor/style/rc/down_arrow.png);
image: url(editor/style/rc/down_arrow.png);
}


Expand All @@ -632,7 +632,7 @@ QTabBar:focus
}

QTabBar::close-button {
image: url(data/editor/style/rc/close.png);
image: url(editor/style/rc/close.png);
background: transparent;
icon-size: 10px;
padding: 5px;
Expand Down Expand Up @@ -769,26 +769,26 @@ QTabBar::tab:right:selected
}

QTabBar QToolButton::right-arrow:enabled {
image: url(data/editor/style/rc/right_arrow.png);
image: url(editor/style/rc/right_arrow.png);
}

QTabBar QToolButton::left-arrow:enabled {
image: url(data/editor/style/rc/left_arrow.png);
image: url(editor/style/rc/left_arrow.png);
}

QTabBar QToolButton::right-arrow:disabled {
image: url(data/editor/style/rc/right_arrow_disabled.png);
image: url(editor/style/rc/right_arrow_disabled.png);
}

QTabBar QToolButton::left-arrow:disabled {
image: url(data/editor/style/rc/left_arrow_disabled.png);
image: url(editor/style/rc/left_arrow_disabled.png);
}


QDockWidget {
border: 1px solid #403F3F;
titlebar-close-icon: url(data/editor/style/rc/close.png);
titlebar-normal-icon: url(data/editor/style/rc/undock.png);
titlebar-close-icon: url(editor/style/rc/close.png);
titlebar-normal-icon: url(editor/style/rc/undock.png);
}

QDockWidget::close-button, QDockWidget::float-button {
Expand All @@ -815,39 +815,39 @@ QTreeView, QListView

QTreeView:branch:selected, QTreeView:branch:hover
{
background: url(data/editor/style/rc/transparent.png);
background: url(editor/style/rc/transparent.png);
}

QTreeView::branch:has-siblings:!adjoins-item {
border-image: url(data/editor/style/rc/transparent.png);
border-image: url(editor/style/rc/transparent.png);
}

QTreeView::branch:has-siblings:adjoins-item {
border-image: url(data/editor/style/rc/transparent.png);
border-image: url(editor/style/rc/transparent.png);
}

QTreeView::branch:!has-children:!has-siblings:adjoins-item {
border-image: url(data/editor/style/rc/transparent.png);
border-image: url(editor/style/rc/transparent.png);
}

QTreeView::branch:has-children:!has-siblings:closed,
QTreeView::branch:closed:has-children:has-siblings {
image: url(data/editor/style/rc/branch_closed.png);
image: url(editor/style/rc/branch_closed.png);
}

QTreeView::branch:open:has-children:!has-siblings,
QTreeView::branch:open:has-children:has-siblings {
image: url(data/editor/style/rc/branch_open.png);
image: url(editor/style/rc/branch_open.png);
}

QTreeView::branch:has-children:!has-siblings:closed:hover,
QTreeView::branch:closed:has-children:has-siblings:hover {
image: url(data/editor/style/rc/branch_closed-on.png);
image: url(editor/style/rc/branch_closed-on.png);
}

QTreeView::branch:open:has-children:!has-siblings:hover,
QTreeView::branch:open:has-children:has-siblings:hover {
image: url(data/editor/style/rc/branch_open-on.png);
image: url(editor/style/rc/branch_open-on.png);
}

QListView::item:!selected:hover, QListView::item:!selected:hover, QTreeView::item:!selected:hover {
Expand Down Expand Up @@ -932,7 +932,7 @@ QToolButton::menu-button {
}

QToolButton::menu-arrow {
image: url(data/editor/style/rc/down_arrow.png);
image: url(editor/style/rc/down_arrow.png);
}

QToolButton::menu-arrow:open {
Expand Down Expand Up @@ -1014,11 +1014,11 @@ QHeaderView::section:checked

/* style the sort indicator */
QHeaderView::down-arrow {
image: url(data/editor/style/rc/down_arrow.png);
image: url(editor/style/rc/down_arrow.png);
}

QHeaderView::up-arrow {
image: url(data/editor/style/rc/up_arrow.png);
image: url(editor/style/rc/up_arrow.png);
}


Expand Down
15 changes: 15 additions & 0 deletions src/core/io/FileUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,21 @@ Path FileUtils::getExecutablePath()
return Path();
}

Path FileUtils::getDataPath()
{
#if _WIN32
Path execPath = getExecutablePath().parent()/"data";
if (execPath.exists())
return std::move(execPath);
return Path(INSTALL_PREFIX)/"data";
#else
Path execPath = getExecutablePath().parent().parent()/"share/tungsten";
if (execPath.exists())
return std::move(execPath);
return Path(INSTALL_PREFIX)/"share/tungsten"
#endif
}

uint64 FileUtils::fileSize(const Path &path)
{
StatStruct info;
Expand Down
1 change: 1 addition & 0 deletions src/core/io/FileUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class FileUtils
static Path getCurrentDir();

static Path getExecutablePath();
static Path getDataPath();

static uint64 fileSize(const Path &path);

Expand Down
2 changes: 1 addition & 1 deletion src/core/primitives/mc-loader/TraceableMinecraftMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ void TraceableMinecraftMap::loadResources()
std::vector<Path> packs;
for (int i = _packPaths.size() - 1; i >= 0; --i)
packs.push_back(*_packPaths[i]);
packs.push_back(FileUtils::getExecutablePath().parent()/"data/mc-loader");
packs.push_back(FileUtils::getDataPath()/"mc-loader");

ResourcePackLoader pack(packs);
buildModels(pack);
Expand Down
3 changes: 1 addition & 2 deletions src/editor/PreviewWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,7 @@ void PreviewWindow::initializeGL()

_fbo.reset(new RenderTarget());

Path exePath = FileUtils::getExecutablePath();
Path shaderBasePath = exePath.parent()/"data/shaders/";
Path shaderBasePath = FileUtils::getDataPath()/"shaders/";

_shader.reset(
new Shader(shaderBasePath, "Preamble.txt", "MeshPreview.vert", "MeshPreview.geom", "MeshPreview.frag", 1));
Expand Down
Loading

0 comments on commit 0ac7a73

Please sign in to comment.