From: Stephane Chauveau Date: Mon, 19 Feb 2018 13:28:12 +0000 (+0100) Subject: [flang] Add simple recursive CMake directory structure X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8f6f23fc54b3d6a88f3b9e7bed469710b1219bb8;p=platform%2Fupstream%2Fllvm.git [flang] Add simple recursive CMake directory structure Original-commit: flang-compiler/f18@a021b2ca768c2b8c03d626739d0754ba99e463d2 Reviewed-on: https://github.com/flang-compiler/f18/pull/13 Tree-same-pre-rewrite: false --- diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index 1f74767..a793493 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -1,42 +1,62 @@ cmake_minimum_required(VERSION 3.9.0) -set(GCC /home/sw/thirdparty/gcc/gcc-7.3.0/linux86-64/redhat) -set(CMAKE_CXX_COMPILER "${GCC}/bin/g++") -set(CMAKE_INSTALL_RPATH "${GCC}/lib64") -set(CMAKE_BUILD_WITH_INSTALL_RPATH true) - -# project(f18) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -std=c++17") -set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DDEBUG") -set(CMAKE_CXX_FLAGS_MINSIZEREL "-O2 '-DCHECK=(void)'") -set(CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG") - -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(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 -) -add_executable(test-type ${SOURCES_TEST_TYPE}) +# +# 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() + +# 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(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(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_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) diff --git a/flang/include/flang/CMakeLists.txt b/flang/include/flang/CMakeLists.txt new file mode 100644 index 0000000..e69de29 diff --git a/flang/lib/CMakeLists.txt b/flang/lib/CMakeLists.txt new file mode 100644 index 0000000..b856b35 --- /dev/null +++ b/flang/lib/CMakeLists.txt @@ -0,0 +1,3 @@ + +add_subdirectory(parser) +add_subdirectory(semantics) diff --git a/flang/lib/parser/CMakeLists.txt b/flang/lib/parser/CMakeLists.txt new file mode 100644 index 0000000..6ab876f --- /dev/null +++ b/flang/lib/parser/CMakeLists.txt @@ -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 +) diff --git a/flang/lib/semantics/CMakeLists.txt b/flang/lib/semantics/CMakeLists.txt new file mode 100644 index 0000000..99ac06e --- /dev/null +++ b/flang/lib/semantics/CMakeLists.txt @@ -0,0 +1,5 @@ + +add_library( FlangSemantics + type.cc + attr.cc +) diff --git a/flang/tools/CMakeLists.txt b/flang/tools/CMakeLists.txt new file mode 100644 index 0000000..5f9f2e5 --- /dev/null +++ b/flang/tools/CMakeLists.txt @@ -0,0 +1,2 @@ + +add_subdirectory(f18) diff --git a/flang/tools/f18/CMakeLists.txt b/flang/tools/f18/CMakeLists.txt new file mode 100644 index 0000000..4e1aa40 --- /dev/null +++ b/flang/tools/f18/CMakeLists.txt @@ -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 + ) + +