cmake: fix clang build and few minor fixes

Change-Id: If5b850c939f7a5383f9a7eff8ac41708c3428a90
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index ae71007..8757053 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -30,6 +30,11 @@
 set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_FLAGS_COMMON} -DCLIB_DEBUG")
 set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_FLAGS_COMMON}")
 
+check_c_compiler_flag("-Wno-address-of-packed-member" compiler_flag_no_address_of_packed_member)
+if (compiler_flag_no_address_of_packed_member)
+  add_definitions(-Wno-address-of-packed-member)
+endif()
+
 ##############################################################################
 # install config
 ##############################################################################
diff --git a/src/cmake/cpu.cmake b/src/cmake/cpu.cmake
index 9a0dfdd..0e1171d 100644
--- a/src/cmake/cpu.cmake
+++ b/src/cmake/cpu.cmake
@@ -17,12 +17,12 @@
 if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
   set(CMAKE_C_FLAGS "-march=corei7 -mtune=corei7-avx ${CMAKE_C_FLAGS}")
   set(VPP_LIB_DIR_NAME lib64)
-  check_c_compiler_flag("-march=core-avx2" AVX2)
-  if(AVX2)
+  check_c_compiler_flag("-march=core-avx2" compiler_flag_march_core_avx2)
+  if(compiler_flag_march_core_avx2)
     list(APPEND MARCH_VARIANTS "avx2\;-march=core-avx2 -mtune=core-avx2")
   endif()
-  check_c_compiler_flag("-march=skylake-avx512" AVX512)
-  if(AVX512)
+  check_c_compiler_flag("-march=skylake-avx512" compiler_flag_march_skylake_avx512)
+  if(compiler_flag_march_skylake_avx512)
     list(APPEND MARCH_VARIANTS "avx512\;-march=skylake-avx512 -mtune=skylake-avx512")
   endif()
 elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
diff --git a/src/vpp-api/vapi/CMakeLists.txt b/src/vpp-api/vapi/CMakeLists.txt
index 8feb12e..103e7c5 100644
--- a/src/vpp-api/vapi/CMakeLists.txt
+++ b/src/vpp-api/vapi/CMakeLists.txt
@@ -50,7 +50,7 @@
   list(APPEND VAPICLIENT_API_CPP_HEADERS ${output})
 endforeach ()
 
-add_custom_target(all-vapi-headers ALL DEPENDS
+add_custom_target(all-vapi-headers DEPENDS
   ${VAPICLIENT_API_C_HEADERS}
   ${VAPICLIENT_API_CPP_HEADERS}
 )
@@ -61,6 +61,7 @@
   libvapiclient.map
 
   LINK_LIBRARIES vppinfra vlibmemoryclient svm pthread m rt
+  DEPENDS all-vapi-headers
 )
 
 install(