Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
if (CMAKE_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right to me.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This says that if the CMAKE_BINARY_DIR is the directory of yosys-slang then you cant build. This makes sense because you could have
./top/CMakeLists.txt # user cmake
./top/yosys-slang/CMakeLists.txt # yosys-slang cmake

when in top/yosys-slang/CMakeLists.txt
CMAKE_SOURCE_DIR is set to "./top"
CMAKE_CURRENT_SOURCE_DIR is set to "./top/yosys-slang"

if they set CMAKE_BINARY_DIR to "./top/yosys-slang" and we are comparing CMAKE_SOURCE_DIR then it would allow the build to be "In-tree". Which is not supported according to the fatal error.

Comparing CMAKE_CURRENT_SOURCE_DIR instead the makes the STREQUAL true and calls the FATAL_ERROR stopping the build from being "In-tree".

When CMAKE_SOURCE_DIR is equal to CMAKE_CURRENT_SOURCE_DIR this will have the same behavior as before the change.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be CMAKE_CURRENT_BINARY_DIR, since we don't support in-tree builds as a subproject either

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, I'll leave the change in.

message(FATAL_ERROR "In-tree builds are not supported. Instead, run:\ncmake . -B build <options> && cmake --build build")
endif()

Expand All @@ -11,7 +11,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project(yosys-slang CXX)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we want the modules to be overridden; this makes accidental name collisions possible where previously they were not

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need it because the default FindYosys.cmake does not work for me. If you think swapping them could break other projects I will remove it from the PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it doesn't work for you then that should be fixed.


option(BUILD_AS_PLUGIN "Build yosys-slang as a plugin" ON)
mark_as_advanced(BUILD_AS_PLUGIN)
Expand Down Expand Up @@ -51,7 +51,7 @@ option(FMT_INSTALL OFF)
FetchContent_Declare(
fmt
EXCLUDE_FROM_ALL
SOURCE_DIR ${CMAKE_SOURCE_DIR}/third_party/fmt
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/fmt
)

set(SLANG_USE_MIMALLOC OFF)
Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
find_package(Yosys)
include(GitRevision)

git_rev_parse(YOSYS_SLANG_REVISION ${CMAKE_SOURCE_DIR})
git_rev_parse(SLANG_REVISION ${CMAKE_SOURCE_DIR}/third_party/slang)
git_rev_parse(YOSYS_SLANG_REVISION ${CMAKE_CURRENT_SOURCE_DIR}/..)
git_rev_parse(SLANG_REVISION ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/slang)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)

if (BUILD_AS_PLUGIN)
Expand Down