changeset 163:a99a7db489bd

CMake: clean up resources and variables, closes #756 @10m
author David Demelier <markand@malikania.fr>
date Sat, 17 Mar 2018 14:26:55 +0100
parents b65a86a84fcb
children a3ba00cdaa7c
files cmake/function/MalikaniaDefineExample.cmake cmake/function/MalikaniaDefineTest.cmake examples/01-bouncing/client.js examples/01-bouncing/fonts/DejaVuSans.ttf examples/animation/main.cpp examples/font/main.cpp examples/image/main.cpp examples/js-animation/main.cpp examples/js-font/main.cpp examples/js-image/main.cpp examples/js-sprite/main.cpp examples/sprite/main.cpp
diffstat 12 files changed, 17 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- a/cmake/function/MalikaniaDefineExample.cmake	Sat Mar 17 14:16:29 2018 +0100
+++ b/cmake/function/MalikaniaDefineExample.cmake	Sat Mar 17 14:26:55 2018 +0100
@@ -32,10 +32,15 @@
         message(FATAL_ERROR "Missing SOURCES parameter")
     endif ()
 
-    list(APPEND EXP_FLAGS SOURCE_DIRECTORY=\"${CMAKE_CURRENT_SOURCE_DIR}/resources\")
     add_executable(example-${EXP_TARGET} ${EXP_SOURCES})
     target_link_libraries(example-${EXP_TARGET} ${EXP_LIBRARIES})
-    target_compile_definitions(example-${EXP_TARGET} PRIVATE ${EXP_FLAGS})
+    target_compile_definitions(
+        example-${EXP_TARGET}
+        PRIVATE
+            CMAKE_CURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
+            CMAKE_CURRENT_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}"
+            ${EXP_FLAGS}
+    )
     set_target_properties(
         example-${EXP_TARGET}
         PROPERTIES
--- a/cmake/function/MalikaniaDefineTest.cmake	Sat Mar 17 14:16:29 2018 +0100
+++ b/cmake/function/MalikaniaDefineTest.cmake	Sat Mar 17 14:26:55 2018 +0100
@@ -77,9 +77,8 @@
         test-${TEST_NAME}
         PRIVATE
             BOOST_TEST_DYN_LINK
-            CMAKE_CURRENT_BINARY_DIR=\"${CMAKE_CURRENT_BINARY_DIR}\"
-            CMAKE_CURRENT_SOURCE_DIR=\"${CMAKE_CURRENT_SOURCE_DIR}\"
-            SOURCE_DIRECTORY=\"${CMAKE_BINARY_DIR}/test/${TEST_NAME}\"
+            CMAKE_CURRENT_BINARY_DIR="${CMAKE_CURRENT_BINARY_DIR}"
+            CMAKE_CURRENT_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
             ${TEST_FLAGS}
     )
 
--- a/examples/01-bouncing/client.js	Sat Mar 17 14:16:29 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-var x = 0;
-var y = 0;
-
-var dx = 1;
-var dy = 1;
-
-var font;
-var clip;
-
-function start(window)
-{
-    font = new Malikania.Font("fonts/DejaVuSans.ttf", 10);
-    clip = font.clip("Malikania");
-
-    x = (640 / 2) - (clip.width / 2);
-    y = (480 / 2) - (clip.height / 2);
-}
-
-function update()
-{
-    x += dx;
-    y += dy;
-
-    if (x >= 640 - clip.width)
-        dx = -1;
-    else if (x <= 0)
-        dx = 1;
-    if (y >= 480 - clip.height)
-        dy = -1;
-    else if (y <= 0)
-        dy = 1;
-}
-
-function draw(window)
-{
-    window.setDrawingColor('lightskyblue');
-    window.clear();
-    window.setDrawingColor('white');
-    window.drawText('Malikania', font, { x: x, y: y });
-    window.present();
-}
Binary file examples/01-bouncing/fonts/DejaVuSans.ttf has changed
--- a/examples/animation/main.cpp	Sat Mar 17 14:16:29 2018 +0100
+++ b/examples/animation/main.cpp	Sat Mar 17 14:26:55 2018 +0100
@@ -32,7 +32,7 @@
     boost::timer::cpu_timer timer;
 
     try {
-        mlk::directory_locator locator(SOURCE_DIRECTORY);
+        mlk::directory_locator locator(CMAKE_CURRENT_SOURCE_DIR "/resources");
         mlk::client::window win(400, 400);
         mlk::client::loader loader(locator);
         mlk::client::animation animation = loader.load_animation("animations/margins.json");
--- a/examples/font/main.cpp	Sat Mar 17 14:16:29 2018 +0100
+++ b/examples/font/main.cpp	Sat Mar 17 14:26:55 2018 +0100
@@ -109,7 +109,7 @@
 {
     try {
         mlk::client::window window(400, 400);
-        mlk::directory_locator locator(SOURCE_DIRECTORY);
+        mlk::directory_locator locator(CMAKE_CURRENT_SOURCE_DIR "/resources");
         mlk::client::loader loader(locator);
         mlk::client::font font = loader.load_font("DejaVuSans.ttf", 10);
 
--- a/examples/image/main.cpp	Sat Mar 17 14:16:29 2018 +0100
+++ b/examples/image/main.cpp	Sat Mar 17 14:26:55 2018 +0100
@@ -49,7 +49,7 @@
 {
     try {
         mlk::client::window window(400, 400);
-        mlk::directory_locator locator(SOURCE_DIRECTORY);
+        mlk::directory_locator locator(CMAKE_CURRENT_SOURCE_DIR "/resources");
         mlk::client::loader loader(locator);
 
         draw(window, loader);
--- a/examples/js-animation/main.cpp	Sat Mar 17 14:16:29 2018 +0100
+++ b/examples/js-animation/main.cpp	Sat Mar 17 14:26:55 2018 +0100
@@ -31,7 +31,7 @@
 int main()
 {
     try {
-        mlk::directory_locator locator(SOURCE_DIRECTORY);
+        mlk::directory_locator locator(CMAKE_CURRENT_SOURCE_DIR "/resources");
         mlk::client::loader loader(locator);
         dukx_context m_ctx;
 
--- a/examples/js-font/main.cpp	Sat Mar 17 14:16:29 2018 +0100
+++ b/examples/js-font/main.cpp	Sat Mar 17 14:26:55 2018 +0100
@@ -51,7 +51,7 @@
 int main()
 {
     try {
-        mlk::directory_locator locator(SOURCE_DIRECTORY);
+        mlk::directory_locator locator(CMAKE_CURRENT_SOURCE_DIR "/resources");
         mlk::client::loader loader(locator);
         dukx_context ctx;
 
--- a/examples/js-image/main.cpp	Sat Mar 17 14:16:29 2018 +0100
+++ b/examples/js-image/main.cpp	Sat Mar 17 14:26:55 2018 +0100
@@ -66,7 +66,7 @@
 int main()
 {
     try {
-        mlk::directory_locator locator(SOURCE_DIRECTORY);
+        mlk::directory_locator locator(CMAKE_CURRENT_SOURCE_DIR "/resources");
         mlk::client::loader loader(locator);
         dukx_context ctx;
 
--- a/examples/js-sprite/main.cpp	Sat Mar 17 14:16:29 2018 +0100
+++ b/examples/js-sprite/main.cpp	Sat Mar 17 14:26:55 2018 +0100
@@ -59,7 +59,7 @@
 int main()
 {
     try {
-        mlk::directory_locator locator(SOURCE_DIRECTORY);
+        mlk::directory_locator locator(CMAKE_CURRENT_SOURCE_DIR "/resources");
         mlk::client::loader loader(locator);
         dukx_context ctx;
 
--- a/examples/sprite/main.cpp	Sat Mar 17 14:16:29 2018 +0100
+++ b/examples/sprite/main.cpp	Sat Mar 17 14:26:55 2018 +0100
@@ -47,7 +47,7 @@
 int main()
 {
     try {
-        mlk::directory_locator locator(SOURCE_DIRECTORY);
+        mlk::directory_locator locator(CMAKE_CURRENT_SOURCE_DIR "/resources");
         mlk::client::loader loader(locator);
         mlk::client::window window(400, 400);