Skip to content

Commit

Permalink
Switch to CMake build system for lfortran runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
certik committed May 14, 2019
1 parent 746fdd2 commit faa9bfa
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
38 changes: 38 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

project(lfort C)

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug
CACHE STRING "Build type (Debug, Release)" FORCE)
endif ()
if (NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR
CMAKE_BUILD_TYPE STREQUAL "Release"))
message("${CMAKE_BUILD_TYPE}")
message(FATAL_ERROR "CMAKE_BUILD_TYPE must be one of: Debug, Release (current value: '${CMAKE_BUILD_TYPE}')")
endif ()

enable_testing()

message("\n")
message("Configuration results")
message("---------------------")
message("C compiler : ${CMAKE_C_COMPILER}")
message("Build type: ${CMAKE_BUILD_TYPE}")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message("C compiler flags : ${CMAKE_C_FLAGS_DEBUG}")
else ()
message("C compiler flags : ${CMAKE_C_FLAGS_RELEASE}")
endif ()
message("Installation prefix: ${CMAKE_INSTALL_PREFIX}")


set(SRC
lfort_intrinsics.c
)
add_library(lfortran ${SRC})
install(TARGETS lfortran
RUNTIME DESTINATION bin
ARCHIVE DESTINATION share/lfortran/lib
LIBRARY DESTINATION share/lfortran/lib
)
12 changes: 4 additions & 8 deletions build1.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
set -e
set -x

# Compile LFort runtime library
CFLAGS="-Wall -g -fPIC"
gcc $CFLAGS -o lfort_intrinsics.o -c lfort_intrinsics.c
ar rcs liblfortran.a lfort_intrinsics.o
gcc -shared -o liblfortran.so lfort_intrinsics.o
mkdir -p share/lfortran/lib
mv liblfortran.a share/lfortran/lib/
mv liblfortran.so share/lfortran/lib/
cmake -DCMAKE_INSTALL_PREFIX=`pwd` -DBUILD_SHARED_LIBS=OFF .
make install
cmake -DCMAKE_INSTALL_PREFIX=`pwd` -DBUILD_SHARED_LIBS=ON .
make install

0 comments on commit faa9bfa

Please sign in to comment.