[flang] Add simple recursive CMake directory structure

Original-commit: flang-compiler/f18@a021b2ca76
Reviewed-on: https://github.com/flang-compiler/f18/pull/13
Tree-same-pre-rewrite: false
This commit is contained in:
Stephane Chauveau 2018-02-19 14:28:12 +01:00
parent 6ca3ca3c6e
commit 8f6f23fc54
7 changed files with 101 additions and 37 deletions

View File

@ -1,42 +1,62 @@
cmake_minimum_required(VERSION 3.9.0)
#
# Reminder: The normal way to set the compiler is via the CXX environment variable
#
# CXX=/opt/gcc-7.2.0/bin/g++ cmake .../f18
#
# but for convenience we provide the following cmake variables to
# use an existing gcc installation directory.
#
# Pass '-DPGI=1' to cmake to use the latest gcc installation at PGI
if( PGI )
set(GCC /home/sw/thirdparty/gcc/gcc-7.3.0/linux86-64/redhat)
endif()
# Pass -DGCC=... to cmake to use a specific gcc installation
if( GCC )
set(CMAKE_CXX_COMPILER "${GCC}/bin/g++")
set(CMAKE_CC_COMPILER "${GCC}/bin/gcc")
set(CMAKE_INSTALL_RPATH "${GCC}/lib64")
set(CMAKE_BUILD_WITH_INSTALL_RPATH true)
endif()
# project(f18)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -std=c++17")
# Reminder: Setting CMAKE_CXX_COMPILER must be done before calling project()
project(f18 CXX)
if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Debug )
endif()
message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}")
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DDEBUG")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-O2 '-DCHECK=(void)'")
set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG")
endif()
set(SOURCES_F18
tools/f18/f18.cc
lib/parser/char-buffer.cc
lib/parser/idioms.cc
lib/parser/message.cc
lib/parser/parse-tree.cc
lib/parser/preprocessor.cc
lib/parser/prescan.cc
lib/parser/provenance.cc
lib/parser/source.cc
lib/parser/token-sequence.cc
)
add_executable(f18 ${SOURCES_F18})
set(FLANG_VERSION_MAJOR "0")
set(FLANG_VERSION_MINOR "1")
set(FLANG_VERSION_PATCHLEVEL "0")
set(FLANG_VERSION "${FLANG_VERSION_MAJOR}.${FLANG_VERSION_MINOR}.${FLANG_VERSION_PATCHLEVEL}")
message(STATUS "FLANG version: ${FLANG_VERSION}")
set(SOURCES_TEST_TYPE
tools/f18/test-type.cc
lib/semantics/type.cc
lib/semantics/attr.cc
lib/parser/char-buffer.cc
lib/parser/idioms.cc
lib/parser/message.cc
lib/parser/parse-tree.cc
lib/parser/preprocessor.cc
lib/parser/prescan.cc
lib/parser/provenance.cc
lib/parser/source.cc
lib/parser/token-sequence.cc
set(FLANG_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(FLANG_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
include_directories(BEFORE
${FLANG_BINARY_DIR}/include
${FLANG_SOURCE_DIR}/include
)
add_executable(test-type ${SOURCES_TEST_TYPE})
add_subdirectory(include/flang)
add_subdirectory(lib)
add_subdirectory(tools)
configure_file(
${FLANG_SOURCE_DIR}/include/flang/Config/config.h.cmake
${FLANG_BINARY_DIR}/include/flang/Config/config.h)

View File

3
flang/lib/CMakeLists.txt Normal file
View File

@ -0,0 +1,3 @@
add_subdirectory(parser)
add_subdirectory(semantics)

View File

@ -0,0 +1,12 @@
add_library( FlangParser
char-buffer.cc
idioms.cc
message.cc
parse-tree.cc
preprocessor.cc
prescan.cc
provenance.cc
source.cc
token-sequence.cc
)

View File

@ -0,0 +1,5 @@
add_library( FlangSemantics
type.cc
attr.cc
)

View File

@ -0,0 +1,2 @@
add_subdirectory(f18)

View File

@ -0,0 +1,22 @@
######## f18 ##########
add_executable( f18
f18.cc
)
target_link_libraries( f18
FlangParser
)
######## test-type ##########
add_executable( test-type
test-type.cc
)
target_link_libraries( test-type
FlangParser
FlangSemantics
)