Skip to content

Commit

Permalink
Fix CMake to allow relative path and add version # to library (#2)
Browse files Browse the repository at this point in the history
* add version for llvm info

* Ensure relative paths

* Fix naming scheme
  • Loading branch information
wsmoses committed May 17, 2021
1 parent 5fd855f commit 14192b6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
19 changes: 18 additions & 1 deletion enzyme/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,38 @@ SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")

set(CMAKE_CXX_STANDARD 11)
cmake_minimum_required(VERSION 3.10)
cmake_minimum_required(VERSION 3.5)

set(ENZYME_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(ENZYME_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})

set(LLVM_SHLIBEXT "${CMAKE_SHARED_MODULE_SUFFIX}")
message( LLVM_SHLIBEXT = ${LLVM_SHLIBEXT} )

get_filename_component(LLVM_ABSOLUTE_DIR
"${LLVM_DIR}"
REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")

set(LLVM_DIR "${LLVM_ABSOLUTE_DIR}" CACHE FILEPATH "b" FORCE)

message("found llvm dir " ${LLVM_DIR})

get_filename_component(LLVM_ABSOLUTE_LIT
"${LLVM_EXTERNAL_LIT}"
REALPATH BASE_DIR "${CMAKE_BINARY_DIR}")

set(LLVM_EXTERNAL_LIT "${LLVM_ABSOLUTE_LIT}" CACHE FILEPATH "a" FORCE)
message("found llvm lit " ${LLVM_EXTERNAL_LIT})

find_package(LLVM REQUIRED CONFIG)
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}")
include(AddLLVM)

add_definitions(${LLVM_DEFINITIONS})
include_directories(${LLVM_INCLUDE_DIRS})
message("found llvm include directory here " ${LLVM_INCLUDE_DIRS})
message("found llvm definitions " ${LLVM_DEFINITIONS})
message("found llvm version " ${LLVM_VERSION_MAJOR})

add_subdirectory(Enzyme)
add_subdirectory(test)
6 changes: 3 additions & 3 deletions enzyme/Enzyme/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
# set(LLVM_LINK_COMPONENTS Core Support)
#endif()

if (${LLVM_VERSION_MAJOR} LESS_EQUAL 7)
add_llvm_loadable_module( LLVMEnzyme
if (${LLVM_VERSION_MAJOR} LESS 8)
add_llvm_loadable_module( LLVMEnzyme-${LLVM_VERSION_MAJOR}
Enzyme.cpp
DEPENDS
intrinsics_gen
PLUGIN_TOOL
opt
)
else()
add_llvm_library( LLVMEnzyme
add_llvm_library( LLVMEnzyme-${LLVM_VERSION_MAJOR}
Enzyme.cpp
MODULE
DEPENDS
Expand Down
2 changes: 1 addition & 1 deletion enzyme/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ configure_lit_site_cfg(
${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
)

set(ENZYME_TEST_DEPS LLVMEnzyme)
set(ENZYME_TEST_DEPS LLVMEnzyme-${LLVM_VERSION_MAJOR})

set(ENZYME_TESTSUITES)
list(APPEND ${CMAKE_CURRENT_BINARY_DIR}/lit.cfg)
Expand Down
3 changes: 2 additions & 1 deletion enzyme/test/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@LIT_SITE_CFG_IN_HEADER@

#config.llvm_src_root = "@LLVM_SOURCE_DIR@"
config.llvm_ver = "@LLVM_VERSION_MAJOR@"
config.llvm_obj_root = "@LLVM_BINARY_DIR@"
config.llvm_tools_dir = "@LLVM_TOOLS_BINARY_DIR@"
config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
Expand Down Expand Up @@ -37,7 +38,7 @@ config.excludes = ['Inputs']

config.substitutions.append(('%shlibext', config.llvm_shlib_ext))
config.substitutions.append(('%loadEnzyme', ''
+ ' -load=@ENZYME_BINARY_DIR@/Enzyme/LLVMEnzyme' + config.llvm_shlib_ext
+ ' -load=@ENZYME_BINARY_DIR@/Enzyme/LLVMEnzyme-' + config.llvm_ver + config.llvm_shlib_ext
))

# Let the main config do the real work.
Expand Down

0 comments on commit 14192b6

Please sign in to comment.