[waffle] [PATCH (master) 2/2] cmake: Set default location for all artifacts to top-level directories

Chad Versace chad.versace at linux.intel.com
Wed Aug 13 14:53:50 PDT 2014


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'.

Cc: Emil Velikov <emil.l.velikov at gmail.com>
Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
---
 CMakeLists.txt            | 7 +++++++
 src/utils/CMakeLists.txt  | 4 ----
 src/waffle/CMakeLists.txt | 2 --
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8e62e40..d599361 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 848702c..4293a8a 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})
-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 3fca87f..51044b2 100644
--- a/src/waffle/CMakeLists.txt
+++ b/src/waffle/CMakeLists.txt
@@ -166,7 +166,6 @@ target_link_libraries(${waffle_libname} ${waffle_libdeps})
 
 set_target_properties(${waffle_libname}
     PROPERTIES
-    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
     SOVERSION ${waffle_soversion}
     VERSION ${waffle_soversion}.${waffle_minor_version}.${waffle_patch_version}
     )
@@ -205,7 +204,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"
     )
 
 # ----------------------------------------------------------------------------
-- 
2.0.4



More information about the waffle mailing list