Skip to content

Commit d5f980f

Browse files
committed
use GnuInstallDirs
1 parent c346658 commit d5f980f

File tree

8 files changed

+76
-3
lines changed

8 files changed

+76
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
build
2+
install
23
*~
34
*.swp

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ project(naja-verilog LANGUAGES CXX)
88

99
set(CMAKE_CXX_STANDARD 20)
1010

11+
include(GNUInstallDirs)
12+
1113
#For Finding flex include path on MacOS with homebrew installation
1214
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /opt/homebrew/opt/flex/include)
1315
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /usr/local/opt/flex/include)

cmake/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
install(FILES FindNajaVerilog.cmake DESTINATION cmake)
5+
install(FILES FindNajaVerilog.cmake DESTINATION ${CMAKE_INSTALL_DATADIR}/naja-verilog/cmake)

src/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ target_include_directories(naja_verilog
3030
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
3131

3232
set_target_properties(naja_verilog PROPERTIES PUBLIC_HEADER "${HEADERS}")
33-
install(TARGETS naja_verilog LIBRARY DESTINATION lib PUBLIC_HEADER DESTINATION include)
33+
install(TARGETS naja_verilog
34+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
35+
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
3436

3537
add_executable(naja_verilog_test NajaVerilogSnippet.cpp)
3638
target_link_libraries(naja_verilog_test naja_verilog)

test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ set(tests
1515
NajaVerilogTest8.cpp
1616
NajaVerilogTest9.cpp
1717
NajaVerilogTest10.cpp
18+
NajaVerilogTest11.cpp
1819
NajaVerilogTestMultipleFiles.cpp
1920
NajaVerilogTestErrors.cpp
2021
)

test/NajaVerilogTest11.cpp

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// SPDX-FileCopyrightText: 2024 The Naja verilog authors <https://github.com/najaeda/naja-verilog/blob/main/AUTHORS>
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
#include "gtest/gtest.h"
6+
7+
#include <filesystem>
8+
#include <fstream>
9+
10+
#include "VerilogConstructor.h"
11+
12+
using namespace naja::verilog;
13+
14+
#include "VerilogConstructorTest.h"
15+
16+
#ifndef NAJA_VERILOG_BENCHMARKS
17+
#define NAJA_VERILOG_BENCHMARKS "Undefined"
18+
#endif
19+
20+
TEST(NajaVerilogTest11, test) {
21+
VerilogConstructorTest constructor;
22+
std::filesystem::path test11Path(
23+
std::filesystem::path(NAJA_VERILOG_BENCHMARKS)
24+
/ std::filesystem::path("benchmarks")
25+
/ std::filesystem::path("test11.v"));
26+
27+
constructor.setFirstPass(true);
28+
constructor.parse(test11Path);
29+
ASSERT_EQ(1, constructor.modules_.size());
30+
auto test = constructor.modules_[0];
31+
EXPECT_TRUE(test->ports_.empty());
32+
EXPECT_TRUE(test->nets_.empty());
33+
EXPECT_TRUE(test->assigns_.empty());
34+
EXPECT_TRUE(test->instances_.empty());
35+
constructor.setFirstPass(false);
36+
constructor.parse(test11Path);
37+
38+
ASSERT_EQ(1, constructor.modules_.size());
39+
EXPECT_TRUE(test->ports_.empty());
40+
EXPECT_TRUE(test->nets_.empty());
41+
EXPECT_TRUE(test->assigns_.empty());
42+
EXPECT_EQ(1, test->instances_.size());
43+
auto instance = test->instances_[0];
44+
EXPECT_EQ("ins", instance.identifier_.name_);
45+
EXPECT_EQ("MOD", instance.model_.name_);
46+
EXPECT_EQ(2, instance.parameterAssignments_.size());
47+
using Parameters = std::vector<std::pair<std::string, std::string>>;
48+
Parameters parameters;
49+
for (const auto& [parameter, value]: instance.parameterAssignments_) {
50+
parameters.push_back({parameter, value});
51+
}
52+
EXPECT_EQ("elem10", parameters[0].first);
53+
EXPECT_EQ("'o0", parameters[0].second);
54+
EXPECT_EQ("elem11", parameters[1].first);
55+
EXPECT_EQ("8'o84", parameters[1].second);
56+
}

test/benchmarks/test11.v

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module test11();
2+
//test octal
3+
4+
MOD
5+
#(
6+
.elem10('o0),
7+
.elem11(8'o84)
8+
)
9+
ins();
10+
11+
endmodule

0 commit comments

Comments
 (0)