Skip to content

Commit

Permalink
reverting dependency mucking
Browse files Browse the repository at this point in the history
  • Loading branch information
fosterbrereton committed Jul 20, 2023
1 parent 8995224 commit 1e17585
Showing 1 changed file with 6 additions and 19 deletions.
25 changes: 6 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ FetchContent_MakeAvailable(llvm)
message(STATUS "INFO: LLVM source dir: ${llvm_SOURCE_DIR}")
message(STATUS "INFO: LLVM binary dir: ${llvm_BINARY_DIR}")

add_executable(hyde)

set(SRC_SOURCES
${PROJECT_SOURCE_DIR}/sources/autodetect.cpp
${PROJECT_SOURCE_DIR}/sources/main.cpp
Expand Down Expand Up @@ -102,15 +104,7 @@ set(SRC_YAMLCPP
${PROJECT_SOURCE_DIR}/submodules/yaml-cpp/src/tag.cpp
)

# We make the hyde sources a library so that we can define these sources as a dependency of the
# executable. This will cause cmake to order the compilation of these files ahead of any other
# dependencies like Clang (because we specify this library as the first dependency of the
# executable.) The big benefit to this change is that they'll get compiled (and possibly
# break) _first_, letting builds fail faster than if Clang we're compiled ahead of these sources.

add_library(hyde_lib STATIC)

target_sources(hyde_lib
target_sources(hyde
PRIVATE
${SRC_SOURCES}
${SRC_EMITTERS}
Expand All @@ -123,7 +117,7 @@ source_group(emitters FILES ${SRC_EMITTERS})
source_group(matchers FILES ${SRC_MATCHERS})
source_group(yaml-cpp FILES ${SRC_YAMLCPP})

target_include_directories(hyde_lib
target_include_directories(hyde
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
Expand All @@ -135,7 +129,7 @@ target_include_directories(hyde_lib
${llvm_BINARY_DIR}/include
)

target_compile_options(hyde_lib
target_compile_options(hyde
PUBLIC
-Wall
-Wno-comment
Expand All @@ -144,18 +138,11 @@ target_compile_options(hyde_lib
)

if (NOT LLVM_ENABLE_RTTI)
target_compile_options(hyde_lib PRIVATE -fno-rtti)
target_compile_options(hyde PRIVATE -fno-rtti)
endif()

# cmake won't let you make an executable with no source files, so we create a dummy empty file.
# See: https://stackoverflow.com/a/34234515/153535
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/null.cpp "// See CMakeLists.txt for the origin of this file.")
add_executable(hyde ${CMAKE_CURRENT_BINARY_DIR}/null.cpp)

target_link_libraries(hyde
# Some Clang dependencies need to build before `hyde_lib` to generate necessary tables.
clang
hyde_lib
clangAST
clangASTMatchers
clangBasic
Expand Down

0 comments on commit 1e17585

Please sign in to comment.