Xuejie Xiao avatar Xuejie Xiao committed 89ea5e1

Fix compiling on clang

Comments (0)

Files changed (3)

 
 include(clReflect)
 
-
 include_directories(
   "${PROJECT_SOURCE_DIR}/src"
   "${PROJECT_SOURCE_DIR}/inc"
 # Creates gen directory manually
 file(MAKE_DIRECTORY "${CL_REFLECT_GEN_DIRECTORY}")
 
+# Test for clang
+if (CMAKE_CXX_COMPILER MATCHES ".*clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+  set(CMAKE_COMPILER_IS_CLANGXX 1)
+endif ()
+
+if (CMAKE_COMPILER_IS_CLANGXX)
+  # TODO: When using clang to compile clreflect, there will be many warnings says switch
+  # does not handle all cases. It will be a big job to fix all cases, so we temporarily
+  # disable this warning here. We may still think of fixing all the code later.
+  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch-enum")
+endif (CMAKE_COMPILER_IS_CLANGXX)
+
 if(MSVC)
   add_definitions(
     /D_SCL_SECURE_NO_WARNINGS

src/clReflectExport/CppExport.cpp

 	}
 
 
+	// forward declarations
+	void LogPrimitive(const clcpp::Field& field);
+	void LogPrimitive(const clcpp::Function& func);
+	void LogPrimitive(const clcpp::EnumConstant& constant);
+	void LogPrimitive(const clcpp::Enum& e);
+	void LogPrimitive(const clcpp::TemplateType& tt);
+	void LogPrimitive(const clcpp::Template& t);
+	void LogPrimitive(const clcpp::Class& cls);
+	void LogPrimitive(const clcpp::Namespace& ns);
+
+
 	template <typename TYPE>
 	void LogPrimitives(const clcpp::CArray<const TYPE*>& primitives)
 	{

src/clReflectScan/CMakeLists.txt

   CACHE PATH "Path to LLVM source.")
 
 set(LLVM_BUILD_DIR_PREDICTION "${CMAKE_CURRENT_SOURCE_DIR}/../../extern/llvm-build")
-if (CMAKE_COMPILER_IS_GNUCXX)
+if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
   set(LLVM_BUILD_DIR_PREDICTION "${CMAKE_CURRENT_SOURCE_DIR}/../../extern/llvm-build-gnu")
-endif (CMAKE_COMPILER_IS_GNUCXX)
+endif (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
 
 set(LLVM_BUILD_DIR ${LLVM_BUILD_DIR_PREDICTION}
   CACHE PATH "Path to LLVM build.")
 include_directories("${LLVM_BUILD_DIR}/include/")
 include_directories("${LLVM_BUILD_DIR}/tools/clang/include")
 
-if (CMAKE_COMPILER_IS_GNUCXX)
-  # GCC flags for stdint.h types
+if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
+  # GCC/Clang flags for stdint.h types
   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -fno-rtti")
-endif (CMAKE_COMPILER_IS_GNUCXX)
+endif (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
 
 set(LLVM_BASE_LIB_DIR "${LLVM_BUILD_DIR}/lib")
 if (MSVC)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.