Skip to content

Commit

Permalink
Merge branch 'newObj' of https://github.com/mvfki/liger into newObj
Browse files Browse the repository at this point in the history
  • Loading branch information
mvfki committed Oct 19, 2023
2 parents 916297c + 0ae1061 commit a0bd940
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 6 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,6 @@ if(OpenMP_CXX_FOUND)
target_include_directories(rliger2 PRIVATE ${OpenMP_CXX_INCLUDE_DIRS})
endif()
endif()
if(WIN32)
target_link_libraries(rliger2 PRIVATE -lgfortran -lgomp -lpthread -ldl -lm -lquadmath "${R_HOME}/bin/x64/R.dll")
endif()
12 changes: 6 additions & 6 deletions cmake/FindR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,38 @@ if(R_EXECUTABLE)
execute_process(
COMMAND ${R_EXECUTABLE} --version
OUTPUT_VARIABLE R_VERSION_STRING
ERROR_VARIABLE R_VERSION_STRING
RESULT_VARIABLE RESULT
)

if(RESULT EQUAL 0)
string(REGEX REPLACE ".*([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1"
R_VERSION_STRING ${R_VERSION_STRING})
R_VERSION_STRING "${R_VERSION_STRING}")
endif()

set(R_HOME ${R_BASE_DIR} CACHE PATH "R home directory obtained from R RHOME")
mark_as_advanced(R_HOME)
endif()

# Find the Rscript program.
find_program(RSCRIPT_EXECUTABLE Rscript DOC "Rscript executable.")
find_program(RSCRIPT_EXECUTABLE Rscript DOC "Rscript executable." HINTS "${R_HOME}/bin")

set(CMAKE_FIND_APPBUNDLE ${TEMP_CMAKE_FIND_APPBUNDLE})

# Search for non-standard R.h include path if header missing

execute_process(COMMAND ${RSCRIPT_EXECUTABLE} "-e" "R.home('include')"
RESULT_VARIABLE _haveR_h
OUTPUT_VARIABLE _R_INCLUDE_location
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
ERROR_VARIABLE _R_INCLUDE_location
OUTPUT_STRIP_TRAILING_WHITESPACE)

# Some cleanup in location of R.
string(REGEX MATCHALL "\".*\"" _R_INCLUDE_location "${_R_INCLUDE_location}")
string(REGEX REPLACE "\"" "" _R_INCLUDE_location "${_R_INCLUDE_location}")
set(R_INCLUDE_DIR ${_R_INCLUDE_location})


mark_as_advanced(RSCRIPT_EXECUTABLE R_EXECUTABLE)
set(_REQUIRED_R_VARIABLES R_EXECUTABLE RSCRIPT_EXECUTABLE)
set(_REQUIRED_R_VARIABLES R_EXECUTABLE RSCRIPT_EXECUTABLE R_INCLUDE_DIR)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
Expand Down
33 changes: 33 additions & 0 deletions configure.ucrt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/sh

if test -z "$CMAKE"; then CMAKE="`which cmake`"; fi
if test -z "$CMAKE"; then CMAKE=/Applications/CMake.app/Contents/bin/cmake; fi
if ! test -f "$CMAKE"; then echo "no ‘cmake’ command found"; exit 1; fi

: ${R_HOME=`R RHOME`}
if test -z "${R_HOME}"; then
echo "could not determine R_HOME"
exit 1
fi
CC=`"${R_HOME}/bin/R" CMD config CC`
CXX=`"${R_HOME}/bin/R" CMD config CXX`
CFLAGS=`"${R_HOME}/bin/R" CMD config CFLAGS`
CPPFLAGS=`"${R_HOME}/bin/R" CMD config --cppflags`
CXXFLAGS=`"${R_HOME}/bin/R" CMD config CXXFLAGS`
LDFLAGS=`"${R_HOME}/bin/R" CMD config --ldflags`
FC=`"${R_HOME}/bin/R" CMD config FC`
FLIBS=`"${R_HOME}/bin/R" CMD config FLIBS`
BLAS_LIBS=`"${R_HOME}/bin/R" CMD config BLAS_LIBS`
LAPACK_LIBS=`"${R_HOME}/bin/R" CMD config LAPACK_LIBS`

CFLAGS="$CPPFLAGS $CFLAGS"
CXXFLAGS="$CPPFLAGS $CXXFLAGS"
LDFLAGS="$BLAS_LIBS $LAPACK_LIBS $LDFLAGS"

cd src
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_POSITION_INDEPENDENT_CODE:bool=ON \
-DR_HOME="$R_HOME"

mv Makefile Makefile.ucrt

0 comments on commit a0bd940

Please sign in to comment.