Last active
May 14, 2023 14:36
-
-
Save MaxClerkwell/f375b8e55e1891388da7f83f66db6726 to your computer and use it in GitHub Desktop.
This Gist helps to get the first Copperspice Tutorial from the CS-Journal running under Ubuntu 20.04. Check out the CS-Journal at https://journal.copperspice.com
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
cspath="$1/lib/cmake/CopperSpice" | |
mkdir -p build | |
cd build | |
cmake -G "Ninja" \ | |
-DCMAKE_PREFIX_PATH="$cspath" \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DCMAKE_INSTALL_PREFIX=../deploy \ | |
.. | |
ninja install |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.16) | |
project(example_1) | |
include(CheckCXXCompilerFlag) | |
include(CheckCXXSourceCompiles) | |
include(CheckIncludeFile) | |
include(CheckIncludeFiles) | |
find_package(CopperSpice REQUIRED) | |
# file locations for installing | |
if (CMAKE_SYSTEM_NAME MATCHES "Darwin") | |
include(GNUInstallDirs) | |
# where libraries are located relative to the executable | |
set(CMAKE_INSTALL_RPATH "@executable_path/../Resources") | |
elseif(CMAKE_SYSTEM_NAME MATCHES "(Linux|OpenBSD|FreeBSD)") | |
include(GNUInstallDirs) | |
set(CMAKE_INSTALL_RPATH "\$ORIGIN") | |
elseif(MSVC) | |
# use defaults | |
elseif(CMAKE_SYSTEM_NAME MATCHES "Windows") | |
set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .) | |
include(${CopperSpice_DIR}/InstallMinGW.cmake) | |
endif() | |
set(CMAKE_INCLUDE_CURRENT_DIR ON) | |
set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON) | |
set(CMAKE_CXX_STANDARD_REQUIRED ON) | |
set(CMAKE_CXX_STANDARD 17) | |
# location for building binary files | |
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) | |
list(APPEND PROJECT_SOURCES | |
${CMAKE_CURRENT_SOURCE_DIR}/example_1.cpp | |
) | |
add_executable(${PROJECT_NAME} ${PROJECT_SOURCES}) | |
if(CMAKE_SYSTEM_NAME MATCHES "Windows") | |
target_link_libraries(${PROJECT_NAME} | |
PRIVATE | |
netapi32 | |
mpr | |
-mwindows | |
) | |
endif() | |
target_link_libraries(${PROJECT_NAME} | |
PRIVATE | |
CopperSpice::CsCore | |
CopperSpice::CsGui | |
) | |
install(TARGETS ${PROJECT_NAME} DESTINATION .) | |
cs_copy_library(CsCore) | |
cs_copy_library(CsGui) | |
# installs the platform Gui plugin | |
cs_copy_plugins(CsGui) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
sudo apt update | |
sudo apt install libfreetype6-dev libfontconfig1-dev libglib2.0-dev libgstreamer1.0-dev \ | |
libgstreamer-plugins-base1.0-dev libice-dev libaudio-dev libgl1-mesa-dev libc6-dev \ | |
libsm-dev libxcursor-dev libxext-dev libxfixes-dev libxi-dev libxinerama-dev \ | |
libxrandr-dev libxrender-dev libxkbcommon-dev libxkbcommon-x11-dev libx11-dev \ | |
libxcb1-dev libx11-xcb-dev libxcb-glx0-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev \ | |
libxcb-render0-dev libxcb-render-util0-dev libxcb-randr0-dev libxcb-shape0-dev \ | |
libxcb-shm0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev libxcb-xkb-dev \ | |
cmake ninja-build clang -y | |
wget https://download.copperspice.com/copperspice/binary/cs-1.7/copperspice-1.7.4-ubuntu20.04-x64.tar.bz2 | |
mkdir cslib | |
tar -xjvf copperspice-1.7.4-ubuntu20.04-x64.tar.bz2 -C ./cslib | |
mkdir example_1 | |
mv CMakeLists.txt example_1.cpp build.sh example_1/ | |
cd example_1 | |
chmod +x build.sh | |
./build.sh ../cslib | |
./deploy/example_1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <QtCore> | |
#include <QtGui> | |
int main(int argc, char *argv[]) | |
{ | |
QApplication app(argc, argv); | |
QWidget *mainWindow = new QWidget(); | |
mainWindow->setMinimumSize(700, 350); | |
QPushButton *pb = new QPushButton(); | |
pb->setText("Close"); | |
QHBoxLayout *layout = new QHBoxLayout(mainWindow); | |
layout->addWidget(pb); | |
QObject::connect(pb, &QPushButton::clicked, | |
mainWindow, &QWidget::close); | |
mainWindow->show(); | |
return app.exec(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment