[waffle] [PATCH] cmake: Set default location for all artifacts to top-level directories

Emil Velikov emil.l.velikov at gmail.com
Mon Aug 18 14:33:45 PDT 2014


From: Chad Versace <chad.versace at linux.intel.com>

By default, put executables into $CMAKE_BINARY_DIR/bin and libraries
into $CMAKE_BINARY_DIR/lib.  Test executables still go into
$CMAKE_BINARY_DIR/test.

This patch's main purpose is to consolidate repetitive code. It doesn't
actually move anything except 'libcmocka.a'.

v2: [Emil]
 - Move gl_basic_test (dynamic linked against waffle) to bin, or the
test will fail on Windows. Due to the DLL being in a different folder.

Cc: Emil Velikov <emil.l.velikov at gmail.com>
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---

Hi Chad,
Had to squash the two patches or the first one would break make check
on Windows.
This patch is based on top of my lasts series "[PATCH 1/4] wgl: 
strings.h does not exist in MSVC", i.e. git branch
"yet-another-round-of-msvc-fixes-1.1"

-Emil

 .gitignore                      | 2 +-
 CMakeLists.txt                  | 7 +++++++
 src/utils/CMakeLists.txt        | 4 ----
 src/waffle/CMakeLists.txt       | 3 ---
 tests/functional/CMakeLists.txt | 5 -----
 5 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/.gitignore b/.gitignore
index f4a0e43..391adf4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,6 +29,7 @@ Makefile
 
 *.so
 
+/bin/gl_basic_test
 /bin/wflinfo
 /doc/html/man/waffle.7.html
 /doc/html/man/waffle_attrib_list.3.html
@@ -55,7 +56,6 @@ Makefile
 /examples/simple-x11-egl
 /lib/
 /src/waffle/libwaffle_static.a
-/tests/functional/gl_basic_test
 /tests/waffle_test/libwaffle_test.dylib
 /tests/unittests/waffle-unittest
 /tests/wcore_attrib_list_unittest
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 53c3e3a..46f1cf2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,6 +29,13 @@ cmake_minimum_required(VERSION 2.8)
 
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
 
+# Set the default location for all build artifacts to traditionally named
+# top-level directories.  CMake's default location for build artifacts varies
+# per artifact and is hard-to-guess.
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
+
 include(WaffleDefineOS)
 include(WaffleFindDependencies)
 include(Options.cmake)
diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt
index 6744c78..9cb6cc7 100644
--- a/src/utils/CMakeLists.txt
+++ b/src/utils/CMakeLists.txt
@@ -4,10 +4,6 @@
 
 add_executable(wflinfo wflinfo.c)
 target_link_libraries(wflinfo ${waffle_libname} ${GETOPT_LIBRARIES})
-set_target_properties(wflinfo
-    PROPERTIES
-        RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
-        )
 
 if(waffle_on_mac)
     set_target_properties(wflinfo
diff --git a/src/waffle/CMakeLists.txt b/src/waffle/CMakeLists.txt
index 954db78..091e4e9 100644
--- a/src/waffle/CMakeLists.txt
+++ b/src/waffle/CMakeLists.txt
@@ -195,8 +195,6 @@ target_link_libraries(${waffle_libname} ${waffle_libdeps})
 
 set_target_properties(${waffle_libname}
     PROPERTIES
-    LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
-    RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
     SOVERSION ${waffle_soversion}
     VERSION ${waffle_soversion}.${waffle_minor_version}.${waffle_patch_version}
     )
@@ -244,7 +242,6 @@ target_link_libraries(waffle_static ${waffle_libdeps})
 set_target_properties(waffle_static
     PROPERTIES
     OUTPUT_NAME "waffle-${waffle_major_version}"
-    ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
     )
 
 # ----------------------------------------------------------------------------
diff --git a/tests/functional/CMakeLists.txt b/tests/functional/CMakeLists.txt
index 1b8fbdc..78bdf54 100644
--- a/tests/functional/CMakeLists.txt
+++ b/tests/functional/CMakeLists.txt
@@ -31,11 +31,6 @@ add_executable(gl_basic_test
 
 # Ensure that the executable is in the same folder as the library it's linke
 # against. Otherwise Windows will fail to load the DLL, and the test will fa
-set_target_properties(gl_basic_test
-    PROPERTIES
-        RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
-)
-
 target_link_libraries(gl_basic_test
     ${waffle_libname}
     waffle_test
-- 
2.0.2



More information about the waffle mailing list