cmake usable?
parent
51d9ce2ed1
commit
c18746942d
14
flake.nix
14
flake.nix
|
@ -26,9 +26,9 @@
|
||||||
default = pkgs.mkShell {
|
default = pkgs.mkShell {
|
||||||
# The Nix packages provided in the environment
|
# The Nix packages provided in the environment
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
boost
|
sfml
|
||||||
|
cmake
|
||||||
gcc
|
gcc
|
||||||
poco
|
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -36,18 +36,18 @@
|
||||||
packages = forAllSystems ({ pkgs }: {
|
packages = forAllSystems ({ pkgs }: {
|
||||||
default =
|
default =
|
||||||
let
|
let
|
||||||
binName = "SFML_Game";
|
binName = "SFMLtest";
|
||||||
cppDependencies = with pkgs; [
|
cppDependencies = with pkgs; [
|
||||||
boost
|
sfml
|
||||||
|
cmake
|
||||||
gcc
|
gcc
|
||||||
poco
|
|
||||||
];
|
];
|
||||||
in
|
in
|
||||||
pkgs.stdenv.mkDerivation {
|
pkgs.stdenv.mkDerivation {
|
||||||
name = "SFML_Game";
|
name = "SFMLtest";
|
||||||
src = self;
|
src = self;
|
||||||
buildInputs = cppDependencies;
|
buildInputs = cppDependencies;
|
||||||
buildPhase = "c++ -std=c++17 -o ${binName} ${./main.cpp} -lPocoFoundation -lboost_system";
|
buildPhase = "c++ -std=c++17 -o ${binName} ${./src/main.cpp} -lPocoFoundation -lboost_system";
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cp ${binName} $out/bin/
|
cp ${binName} $out/bin/
|
||||||
|
|
5
main.cpp
5
main.cpp
|
@ -1,5 +0,0 @@
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
int main() {
|
|
||||||
std::cout << "Hello from Nix + C++!\n";
|
|
||||||
}
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
cmake_minimum_required(VERSION 3.17)
|
||||||
|
|
||||||
|
project(SFMLtest)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin/")
|
||||||
|
|
||||||
|
find_package(SFML 2.5.1 COMPONENTS system graphics audio REQUIRED)
|
||||||
|
|
||||||
|
file(GLOB_RECURSE
|
||||||
|
SOURCE
|
||||||
|
"${CMAKE_SOURCE_DIR}/src/**.cpp")
|
||||||
|
|
||||||
|
add_executable(SFMLtest ${SOURCE})
|
||||||
|
|
||||||
|
target_link_libraries(SFMLtest sfml-system sfml-window sfml-graphics sfml-audio)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
sf::RenderWindow window(sf::VideoMode(640, 480), "SFML Application");
|
||||||
|
sf::CircleShape shape;
|
||||||
|
shape.setRadius(40.f);
|
||||||
|
shape.setPosition(100.f, 100.f);
|
||||||
|
shape.setFillColor(sf::Color::Cyan);
|
||||||
|
while (window.isOpen())
|
||||||
|
{
|
||||||
|
sf::Event event;
|
||||||
|
while (window.pollEvent(event))
|
||||||
|
{
|
||||||
|
if (event.type == sf::Event::Closed)
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
window.clear();
|
||||||
|
window.draw(shape);
|
||||||
|
window.display();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue