[HIPIFY] cmake changes
+ standalone build support
+ WIN MSVC support
+ disable lit testing by default
+ to enable lit testing -DHIPIFY_CLANG_TESTS=1 should be specified
Tested builds:
+ hipify-clang standalone {Ubuntu 16.04|Windows 10} {Debug|Release} {x86|x64a} {g++|clang++|MSVC 2017} {llvm 3.8.0|llvm 3.9.0} {-DHIPIFY_CLANG_TESTS=1| }
+ HIP {-DHIPIFY_CLANG_LLVM_DIR=..|} {Ubuntu 16.04} {Debug|Release} {x86|x64a} {hcc} {llvm 3.8.0|llvm 3.9.0} {-DHIPIFY_CLANG_TESTS=1| }
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
cmake_minimum_required(VERSION 2.8.8)
|
||||
project(hipify-clang)
|
||||
|
||||
set(BUILD_HIPIFY_CLANG 0 PARENT_SCOPE)
|
||||
if (PARENT_SCOPE)
|
||||
set(BUILD_HIPIFY_CLANG 0 PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
# Find LLVM package
|
||||
find_package(LLVM 3.8 QUIET PATHS ${HIPIFY_CLANG_LLVM_DIR} NO_DEFAULT_PATH)
|
||||
if (NOT ${LLVM_FOUND})
|
||||
find_package(LLVM 3.9 QUIET PATHS ${HIPIFY_CLANG_LLVM_DIR} NO_DEFAULT_PATH)
|
||||
if (NOT ${LLVM_FOUND})
|
||||
message(STATUS "hipify-clang will not be built. To build it please specify absolute path to LLVM 3.8 or LLVM 3.9 package using -DHIPIFY_CLANG_LLVM_DIR")
|
||||
message(STATUS "hipify-clang will not be built. To build it please specify absolute path to LLVM 3.8 or LLVM 3.9 package/dist using -DHIPIFY_CLANG_LLVM_DIR")
|
||||
endif()
|
||||
endif()
|
||||
if (${LLVM_FOUND})
|
||||
@@ -21,12 +23,11 @@ if (${LLVM_FOUND})
|
||||
link_directories(${LLVM_LIBRARY_DIRS})
|
||||
add_definitions(${LLVM_DEFINITIONS})
|
||||
add_llvm_executable(hipify-clang src/Cuda2Hip.cpp)
|
||||
find_program(LIT_COMMAND lit)
|
||||
|
||||
set(CMAKE_CXX_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang++)
|
||||
set(CMAKE_C_COMPILER ${LLVM_TOOLS_BINARY_DIR}/clang)
|
||||
|
||||
# Link against LLVM and CLANG tools libraries
|
||||
# Link against LLVM and CLANG libraries
|
||||
target_link_libraries(hipify-clang
|
||||
clangASTMatchers
|
||||
clangFrontend
|
||||
@@ -51,22 +52,35 @@ if (${LLVM_FOUND})
|
||||
LLVMOption
|
||||
LLVMCore)
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(hipify-clang version)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
|
||||
if(MSVC)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GR- /EHs- /EHc-")
|
||||
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} /SUBSYSTEM:WINDOWS")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -pthread -fno-rtti -fvisibility-inlines-hidden")
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHIPIFY_CLANG_RES=\\\"${LLVM_LIBRARY_DIRS}/clang/${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}.${LLVM_VERSION_PATCH}\\\"")
|
||||
|
||||
install(TARGETS hipify-clang DESTINATION bin)
|
||||
|
||||
if (HIPIFY_CLANG_TESTS)
|
||||
# tests
|
||||
set(Python_ADDITIONAL_VERSIONS 2.7)
|
||||
include(FindPythonInterp)
|
||||
if(NOT PYTHONINTERP_FOUND)
|
||||
message(FATAL_ERROR
|
||||
"Unable to find Python interpreter, required for builds and testing\n\n"
|
||||
"Unable to find Python interpreter, required for builds and testing.\n\n"
|
||||
"Please install Python or specify the PYTHON_EXECUTABLE CMake variable.")
|
||||
endif()
|
||||
|
||||
find_program(LIT_COMMAND lit)
|
||||
|
||||
set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
configure_file(
|
||||
@@ -83,8 +97,10 @@ if (${LLVM_FOUND})
|
||||
add_custom_target(test-hipify-clang)
|
||||
add_dependencies(test-hipify-clang test-hipify)
|
||||
set_target_properties(test-hipify-clang PROPERTIES FOLDER "Tests")
|
||||
endif()
|
||||
|
||||
if (PARENT_SCOPE)
|
||||
set(BUILD_HIPIFY_CLANG 1 PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
# vim: ts=4:sw=4:expandtab:smartindent
|
||||
endif()
|
||||
|
||||
Fai riferimento in un nuovo problema
Block a user