cmake: Fix ninja build. (#6481)
authorMathias Preiner <mathias.preiner@gmail.com>
Tue, 4 May 2021 16:55:28 +0000 (09:55 -0700)
committerGitHub <noreply@github.com>
Tue, 4 May 2021 16:55:28 +0000 (16:55 +0000)
cmake/FindCaDiCaL.cmake
cmake/FindKissat.cmake

index 9f8289cb99002beb5e5a57af9ebf9c5ddf121ea9..a2bead06bea240b4d1364b604868e7530ee5a64d 100644 (file)
@@ -61,6 +61,14 @@ if(NOT CaDiCaL_FOUND_SYSTEM)
     set(CXXFLAGS "${CXXFLAGS} -DNUNLOCKED")
   endif()
 
+  if("${CMAKE_GENERATOR}" STREQUAL "Unix Makefiles")
+    # use $(MAKE) instead of "make" to allow for parallel builds
+    set(make_cmd "$(MAKE)")
+  else()
+    # $(MAKE) does not work with ninja
+    set(make_cmd "make")
+  endif()
+
   ExternalProject_Add(
     CaDiCaL-EP
     ${COMMON_EP_CONFIG}
@@ -75,12 +83,12 @@ if(NOT CaDiCaL_FOUND_SYSTEM)
       sed -i.orig -e "s,@CXX@,${CMAKE_CXX_COMPILER}," -e
       "s,@CXXFLAGS@,${CXXFLAGS}," -e "s,@MAKEFLAGS@,,"
       <SOURCE_DIR>/build/makefile
-    # use $(MAKE) instead of "make" to allow for parallel builds
-    BUILD_COMMAND $(MAKE) -C <SOURCE_DIR>/build libcadical.a
+    BUILD_COMMAND ${make_cmd} -C <SOURCE_DIR>/build libcadical.a
     INSTALL_COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/build/libcadical.a
                     <INSTALL_DIR>/lib/libcadical.a
     COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/src/cadical.hpp
             <INSTALL_DIR>/include/cadical.hpp
+    BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libcadical.a
   )
 
   set(CaDiCaL_INCLUDE_DIR "${DEPS_BASE}/include/")
index 08b214961454133d474bf481804d1f7cb4b1e4e2..e257d2b3d2384109ccbc53521af8106f91c85a24 100644 (file)
@@ -63,6 +63,7 @@ if(NOT Kissat_FOUND_SYSTEM)
                     <INSTALL_DIR>/lib/libkissat.a
     COMMAND ${CMAKE_COMMAND} -E copy <SOURCE_DIR>/src/kissat.h
             <INSTALL_DIR>/include/kissat/kissat.h
+    BUILD_BYPRODUCTS <INSTALL_DIR>/lib/libkissat.a
   )
 
   set(Kissat_INCLUDE_DIR "${DEPS_BASE}/include/")