Rather than wrapping around cmocka's existing cmake, simply inherit the build setup/variables from the waffle project and build a simple cmocka static library. This way we'll no longer need to add the custom commands for build and we'll be able to easily handle mingw-w64 and msvc build :)
To make things even better this speeds up the configure/build process. Patch is largely written by Nils Gladitz, ngladitz on #cmake Signed-off-by: Emil Velikov <[email protected]> --- A small lovely patch strictly speaking not part of this series. Yet I've that I had it locally for ages, and without it the "fix-make-check" will not work at all :'( -Emil cmake/Modules/WaffleCMocka.cmake | 58 +++------------------------------------- 1 file changed, 4 insertions(+), 54 deletions(-) diff --git a/cmake/Modules/WaffleCMocka.cmake b/cmake/Modules/WaffleCMocka.cmake index e276acd..9222645 100644 --- a/cmake/Modules/WaffleCMocka.cmake +++ b/cmake/Modules/WaffleCMocka.cmake @@ -24,60 +24,10 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. set(cmocka_source_dir ${CMAKE_SOURCE_DIR}/third_party/cmocka) -set(cmocka_build_dir ${CMAKE_BINARY_DIR}/third_party/cmocka/build) -set(cmocka_cmake_output_file ${cmocka_build_dir}/waffle-cmake.log) -set(cmocka_cmake_error_file ${cmocka_build_dir}/waffle-cmake.err) -set(cmocka_cmake_command "cd \"${cmocka_build_dir}\" && cmake -G\"${CMAKE_GENERATOR}\" -DCMAKE_C_COMPILER=\"${CMAKE_C_COMPILER}\" \"${cmocka_source_dir}\"") -if(waffle_on_linux) - set(cmocka_library_location ${cmocka_build_dir}/src/libcmocka.so) -elseif(waffle_on_mac) - set(cmocka_library_location ${cmocka_build_dir}/src/libcmocka.dylib) -endif() - -include_directories(${cmocka_source_dir}/include) -link_directories(${cmocka_build_dir}/src) - -add_library(cmocka SHARED IMPORTED) -set_target_properties(cmocka - PROPERTIES - IMPORTED_LOCATION ${cmocka_library_location} -) -add_dependencies(cmocka cmocka-build) -add_custom_command( - OUTPUT ${cmocka_library_location} - WORKING_DIRECTORY ${cmocka_build_dir} - COMMAND cmake --build . -) - -add_custom_target(cmocka-build - DEPENDS ${cmocka_library_location} -) -add_custom_target(cmocka-clean - WORKING_DIRECTORY ${cmocka_build_dir} - COMMAND cmake --build . --target clean +list(APPEND CMOCKA_SOURCES + ${cmocka_source_dir}/src/cmocka.c ) -# Configure CMocka. -if(NOT EXISTS ${cmocka_build_dir}/CMakeCache.txt) - file(MAKE_DIRECTORY ${cmocka_build_dir}) - message(STATUS "Configuring subproject third_party/cmocka") - message(STATUS "${cmocka_cmake_command}") - execute_process( - COMMAND sh -c ${cmocka_cmake_command} - RESULT_VARIABLE cmocka_cmake_result - OUTPUT_FILE ${cmocka_cmake_output_file} - ERROR_FILE ${cmocka_cmake_error_file} - ) - if(NOT ${cmocka_cmake_result} EQUAL 0) - if(EXISTS ${cmocka_cmake_error_file}) - message(STATUS "Error messages from subproject third_party/cmocka:") - message(STATUS) - execute_process(COMMAND cat ${cmocka_cmake_error_file}) - endif() - message(STATUS "See following files for details on cmocka configuration failure::") - message(STATUS " ${cmocka_cmake_output_file}") - message(STATUS " ${cmocka_cmake_error_file}") - message(FATAL_ERROR "Failed to configure subproject third_party/cmocka") - endif() -endif() +add_library(cmocka STATIC ${cmocka_source_dir}/src/cmocka.c) +target_include_directories(cmocka PUBLIC ${cmocka_source_dir}/include) -- 2.0.2 _______________________________________________ waffle mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/waffle

