Browse Source

Modernized CMake

Eyck Jentzsch 4 months ago
parent
commit
2758933c16
3 changed files with 96 additions and 100 deletions
  1. 94
    5
      CMakeLists.txt
  2. 2
    8
      softfloat/CMakeLists.txt
  3. 0
    87
      src/CMakeLists.txt

+ 94
- 5
CMakeLists.txt View File

@@ -7,8 +7,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
7 7
 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") 
8 8
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
9 9
 
10
-add_subdirectory(softfloat)
11
-
12 10
 # Set the name of your project here
13 11
 project("riscv")
14 12
 
@@ -22,8 +20,7 @@ include_directories(
22 20
 	${SOFTFLOAT_INCLUDE_DIRS}
23 21
     ${LLVM_INCLUDE_DIRS}
24 22
 )
25
-add_dependent_subproject(dbt-core)
26
-add_dependent_subproject(sc-components)
23
+
27 24
 include_directories(
28 25
     ${PROJECT_SOURCE_DIR}/incl
29 26
     ${PROJECT_SOURCE_DIR}/../external/elfio
@@ -39,7 +36,99 @@ set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
39 36
 set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
40 37
 set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
41 38
 
42
-add_subdirectory(src)
39
+add_subdirectory(softfloat)
40
+
41
+# library files
42
+FILE(GLOB RiscVSCHeaders ${CMAKE_CURRENT_SOURCE_DIR}/incl/sysc/*.h ${CMAKE_CURRENT_SOURCE_DIR}/incl/sysc/*/*.h)
43
+set(LIB_HEADERS ${RiscVSCHeaders} )
44
+set(LIB_SOURCES 
45
+	src/iss/rv32gc.cpp
46
+	src/iss/rv32imac.cpp
47
+	src/iss/rv64i.cpp
48
+	src/iss/rv64gc.cpp
49
+	src/internal/fp_functions.cpp
50
+	src/internal/vm_rv32gc.cpp
51
+	src/internal/vm_rv32imac.cpp
52
+	src/internal/vm_rv64i.cpp
53
+	src/internal/vm_rv64gc.cpp
54
+    src/plugin/instruction_count.cpp
55
+    src/plugin/cycle_estimate.cpp)
56
+
57
+# Define two variables in order not to repeat ourselves.
58
+set(LIBRARY_NAME riscv)
59
+
60
+# Define the library
61
+add_library(${LIBRARY_NAME} ${LIB_SOURCES})
62
+SET(${LIBRARY_NAME} -Wl,-whole-archive -l${LIBRARY_NAME} -Wl,-no-whole-archive)
63
+target_link_libraries(${LIBRARY_NAME} softfloat)
64
+target_link_libraries(${LIBRARY_NAME} dbt-core)
65
+target_link_libraries(${LIBRARY_NAME} scc)
66
+set_target_properties(${LIBRARY_NAME} PROPERTIES
67
+  VERSION ${VERSION}  # ${VERSION} was defined in the main CMakeLists.
68
+  FRAMEWORK FALSE
69
+  PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
70
+)
71
+#set_property(TARGET ${LIBRARY_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)
72
+
73
+if(SystemC_FOUND)
74
+	set(SC_LIBRARY_NAME riscv_sc)
75
+	add_library(${SC_LIBRARY_NAME} SHARED src/sysc/core_complex.cpp)
76
+	add_definitions(-DWITH_SYSTEMC) 
77
+	include_directories(${SystemC_INCLUDE_DIRS})
78
+	
79
+	include_directories(${CCI_INCLUDE_DIRS})
80
+	
81
+	if(SCV_FOUND)   
82
+	    add_definitions(-DWITH_SCV)
83
+	    include_directories(${SCV_INCLUDE_DIRS})
84
+	endif()
85
+	target_link_libraries(${SC_LIBRARY_NAME} ${LIBRARY_NAME})
86
+	target_link_libraries(${SC_LIBRARY_NAME} dbt-core)
87
+	target_link_libraries(${SC_LIBRARY_NAME} softfloat)
88
+	target_link_libraries(${SC_LIBRARY_NAME} scc)
89
+	target_link_libraries(${SC_LIBRARY_NAME} external)
90
+	target_link_libraries(${SC_LIBRARY_NAME} ${llvm_libs})
91
+	target_link_libraries(${SC_LIBRARY_NAME} ${Boost_LIBRARIES} )
92
+	set_target_properties(${SC_LIBRARY_NAME} PROPERTIES
93
+	  VERSION ${VERSION}  # ${VERSION} was defined in the main CMakeLists.
94
+	  FRAMEWORK FALSE
95
+	  PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
96
+	)
97
+endif()
98
+
99
+# This is a make target, so you can do a "make riscv-sc"
100
+set(APPLICATION_NAME riscv-sim)
101
+
102
+add_executable(${APPLICATION_NAME} src/main.cpp)
103
+
104
+# Links the target exe against the libraries
105
+target_link_libraries(${APPLICATION_NAME} ${LIBRARY_NAME})
106
+target_link_libraries(${APPLICATION_NAME} jsoncpp)
107
+target_link_libraries(${APPLICATION_NAME} dbt-core)
108
+target_link_libraries(${APPLICATION_NAME} softfloat)
109
+target_link_libraries(${APPLICATION_NAME} external)
110
+target_link_libraries(${APPLICATION_NAME} ${llvm_libs})
111
+target_link_libraries(${APPLICATION_NAME} ${Boost_LIBRARIES} )
112
+if (Tcmalloc_FOUND)
113
+    target_link_libraries(${APPLICATION_NAME} ${Tcmalloc_LIBRARIES})
114
+endif(Tcmalloc_FOUND)
115
+
116
+# Says how and where to install software
117
+# Targets:
118
+#   * <prefix>/lib/<libraries>
119
+#   * header location after install: <prefix>/include/<project>/*.h
120
+#   * headers can be included by C++ code `#<project>/Bar.hpp>`
121
+install(TARGETS ${LIBRARY_NAME} ${APPLICATION_NAME}
122
+  EXPORT ${PROJECT_NAME}Targets            # for downstream dependencies
123
+  ARCHIVE DESTINATION lib COMPONENT libs   # static lib
124
+  RUNTIME DESTINATION bin COMPONENT libs   # binaries
125
+  LIBRARY DESTINATION lib COMPONENT libs   # shared lib
126
+  FRAMEWORK DESTINATION bin COMPONENT libs # for mac
127
+  PUBLIC_HEADER DESTINATION incl/${PROJECT_NAME} COMPONENT devel   # headers for mac (note the different component -> different package)
128
+  INCLUDES DESTINATION incl             # headers
129
+)
130
+
131
+
43 132
 
44 133
 #
45 134
 # SYSTEM PACKAGING (RPM, TGZ, ...)

+ 2
- 8
softfloat/CMakeLists.txt View File

@@ -26,13 +26,6 @@ add_definitions(
26 26
 #  	-DTHREAD_LOCAL=__thread
27 27
 )
28 28
 
29
-set(SOFTFLOAT_INCLUDE_DIRS
30
-    ${PROJECT_SOURCE_DIR}/build/Linux-x86_64-GCC
31
-    ${PROJECT_SOURCE_DIR}/source/include
32
-    ${PROJECT_SOURCE_DIR}/source/${SPECIALIZATION}
33
-)
34
-
35
-include_directories(${SOFTFLOAT_INCLUDE_DIRS})
36 29
 
37 30
 set(LIB_HEADERS source/include/softfloat.h source/include/softfloat_types.h)
38 31
 set(PRIMITIVES
@@ -354,6 +347,8 @@ set(LIBRARY_NAME softfloat)
354 347
 # Define the library
355 348
 add_library(${LIBRARY_NAME} ${LIB_SOURCES})
356 349
 set_property(TARGET ${LIBRARY_NAME} PROPERTY C_STANDARD 99)
350
+target_include_directories(${LIBRARY_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/build/Linux-x86_64-GCC)
351
+target_include_directories(${LIBRARY_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/source/include ${CMAKE_CURRENT_SOURCE_DIR}/source/${SPECIALIZATION})
357 352
 # Set the build version. It will be used in the name of the lib, with corresponding
358 353
 # symlinks created. SOVERSION could also be specified for api version. 
359 354
 set_target_properties(${LIBRARY_NAME} PROPERTIES
@@ -361,7 +356,6 @@ set_target_properties(${LIBRARY_NAME} PROPERTIES
361 356
   FRAMEWORK FALSE
362 357
   PUBLIC_HEADER "${LIB_HEADERS}"
363 358
 )
364
-target_include_directories (softfloat PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/source/include)
365 359
 
366 360
 # Says how and where to install software
367 361
 # Targets:

+ 0
- 87
src/CMakeLists.txt View File

@@ -1,87 +0,0 @@
1
-# library files
2
-FILE(GLOB RiscVSCHeaders ${PROJECT_SOURCE_DIR}/incl/sysc/*.h ${PROJECT_SOURCE_DIR}/incl/sysc/*/*.h)
3
-set(LIB_HEADERS ${RiscVSCHeaders} )
4
-set(LIB_SOURCES 
5
-	iss/rv32gc.cpp
6
-	iss/rv32imac.cpp
7
-	iss/rv64i.cpp
8
-	iss/rv64gc.cpp
9
-	internal/fp_functions.cpp
10
-	internal/vm_rv32gc.cpp
11
-	internal/vm_rv32imac.cpp
12
-	internal/vm_rv64i.cpp
13
-	internal/vm_rv64gc.cpp
14
-    plugin/instruction_count.cpp
15
-    plugin/cycle_estimate.cpp)
16
-
17
-# Define two variables in order not to repeat ourselves.
18
-set(LIBRARY_NAME riscv)
19
-
20
-# Define the library
21
-add_library(${LIBRARY_NAME} ${LIB_SOURCES})
22
-SET(${LIBRARY_NAME} -Wl,-whole-archive -l${LIBRARY_NAME} -Wl,-no-whole-archive)
23
-set_target_properties(${LIBRARY_NAME} PROPERTIES
24
-  VERSION ${VERSION}  # ${VERSION} was defined in the main CMakeLists.
25
-  FRAMEWORK FALSE
26
-  PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
27
-)
28
-#set_property(TARGET ${LIBRARY_NAME} PROPERTY POSITION_INDEPENDENT_CODE ON)
29
-
30
-if(SystemC_FOUND)
31
-	set(SC_LIBRARY_NAME riscv_sc)
32
-	add_library(${SC_LIBRARY_NAME} SHARED sysc/core_complex.cpp)
33
-	add_definitions(-DWITH_SYSTEMC) 
34
-	include_directories(${SystemC_INCLUDE_DIRS})
35
-	
36
-	include_directories(${CCI_INCLUDE_DIRS})
37
-	
38
-	if(SCV_FOUND)   
39
-	    add_definitions(-DWITH_SCV)
40
-	    include_directories(${SCV_INCLUDE_DIRS})
41
-	endif()
42
-	set_target_properties(${SC_LIBRARY_NAME} PROPERTIES
43
-	  VERSION ${VERSION}  # ${VERSION} was defined in the main CMakeLists.
44
-	  FRAMEWORK FALSE
45
-	  PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
46
-	)
47
-	target_link_libraries(${SC_LIBRARY_NAME} ${LIBRARY_NAME})
48
-	target_link_libraries(${SC_LIBRARY_NAME} dbt-core)
49
-	target_link_libraries(${SC_LIBRARY_NAME} softfloat)
50
-	target_link_libraries(${SC_LIBRARY_NAME} sc-components)
51
-	target_link_libraries(${SC_LIBRARY_NAME} external)
52
-	target_link_libraries(${SC_LIBRARY_NAME} ${llvm_libs})
53
-	target_link_libraries(${SC_LIBRARY_NAME} ${Boost_LIBRARIES} )
54
-endif()
55
-
56
-# This is a make target, so you can do a "make riscv-sc"
57
-set(APPLICATION_NAME riscv-sim)
58
-
59
-add_executable(${APPLICATION_NAME} main.cpp)
60
-
61
-# Links the target exe against the libraries
62
-target_link_libraries(${APPLICATION_NAME} ${LIBRARY_NAME})
63
-target_link_libraries(${APPLICATION_NAME} jsoncpp)
64
-target_link_libraries(${APPLICATION_NAME} dbt-core)
65
-target_link_libraries(${APPLICATION_NAME} softfloat)
66
-target_link_libraries(${APPLICATION_NAME} external)
67
-target_link_libraries(${APPLICATION_NAME} ${llvm_libs})
68
-target_link_libraries(${APPLICATION_NAME} ${Boost_LIBRARIES} )
69
-if (Tcmalloc_FOUND)
70
-    target_link_libraries(${APPLICATION_NAME} ${Tcmalloc_LIBRARIES})
71
-endif(Tcmalloc_FOUND)
72
-
73
-# Says how and where to install software
74
-# Targets:
75
-#   * <prefix>/lib/<libraries>
76
-#   * header location after install: <prefix>/include/<project>/*.h
77
-#   * headers can be included by C++ code `#<project>/Bar.hpp>`
78
-install(TARGETS ${LIBRARY_NAME} ${APPLICATION_NAME}
79
-  EXPORT ${PROJECT_NAME}Targets            # for downstream dependencies
80
-  ARCHIVE DESTINATION lib COMPONENT libs   # static lib
81
-  RUNTIME DESTINATION bin COMPONENT libs   # binaries
82
-  LIBRARY DESTINATION lib COMPONENT libs   # shared lib
83
-  FRAMEWORK DESTINATION bin COMPONENT libs # for mac
84
-  PUBLIC_HEADER DESTINATION incl/${PROJECT_NAME} COMPONENT devel   # headers for mac (note the different component -> different package)
85
-  INCLUDES DESTINATION incl             # headers
86
-)
87
-