Browse Source

Added option to build as shared library

Eyck Jentzsch 11 months ago
parent
commit
a007bd6792
1 changed files with 33 additions and 4 deletions
  1. 33
    4
      src/CMakeLists.txt

+ 33
- 4
src/CMakeLists.txt View File

@@ -1,4 +1,4 @@
1
-FILE(GLOB LibHeaders *.h)
1
+FILE(GLOB LibHeaders ../incl/*/*.h)
2 2
 set(LIB_HEADERS ${LibHeaders} )
3 3
 set(LIB_SOURCES
4 4
     sc_logic_7.cpp
@@ -30,7 +30,36 @@ endif(SCV_FOUND)
30 30
 set(LIBRARY_NAME sc-components)
31 31
 
32 32
 # Define the library
33
-add_library(${LIBRARY_NAME} ${LIB_SOURCES})
34
-# Make sure the compiler can find include files for our library
35
-# when other libraries or executables link to sc_components
33
+if(ENABLE_SHARED)
34
+	add_library(${LIBRARY_NAME} SHARED ${LIB_SOURCES})
35
+	include_directories(${SystemC_INCLUDE_DIRS})	
36
+	include_directories(${CCI_INCLUDE_DIRS})
37
+	if(SCV_FOUND)   
38
+	    add_definitions(-DWITH_SCV)
39
+	    include_directories(${SCV_INCLUDE_DIRS})
40
+	endif()
41
+	set_target_properties(${LIBRARY_NAME} PROPERTIES
42
+	  VERSION ${VERSION}  # ${VERSION} was defined in the main CMakeLists.
43
+	  FRAMEWORK FALSE
44
+	  PUBLIC_HEADER "${LIB_HEADERS}" # specify the public headers
45
+	)
46
+	target_link_libraries(${LIBRARY_NAME} ${CCI_LIBRARIES} )
47
+	if(SCV_FOUND)
48
+	    link_directories(${LIBRARY_NAME})
49
+	    target_link_libraries (${LIBRARY_NAME} ${SCV_LIBRARIES})
50
+	endif()
51
+	target_link_libraries(${LIBRARY_NAME} ${SystemC_LIBRARIES} )
52
+	# build a separate JSON linrary for the use in non-systemc based systems
53
+	add_library(jsoncpp jsoncpp.cpp)
54
+	FILE(GLOB JsonLibHeaders ../incl/json/*.h)
55
+	set_target_properties(jsoncpp PROPERTIES
56
+	  VERSION ${VERSION}  # ${VERSION} was defined in the main CMakeLists.
57
+	  FRAMEWORK FALSE
58
+	  PUBLIC_HEADER "${JsonLibHeaders}" # specify the public headers
59
+	)
60
+	target_include_directories (jsoncpp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../incl)
61
+else()
62
+	add_library(${LIBRARY_NAME} ${LIB_SOURCES})
63
+endif()
36 64
 target_include_directories (sc-components PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../incl)
65
+