2020-01-20 19:14:24 -06:00
|
|
|
cmake_minimum_required(VERSION 3.9)
|
|
|
|
|
2020-01-21 21:46:24 -06:00
|
|
|
project("libopenfpgashell")
|
2020-01-20 19:14:24 -06:00
|
|
|
|
2020-01-21 23:59:53 -06:00
|
|
|
# We need readline to compile
|
|
|
|
find_package(Readline REQUIRED)
|
|
|
|
|
2022-08-24 21:56:35 -05:00
|
|
|
file(GLOB_RECURSE EXEC_SOURCES test/*.cpp)
|
2020-01-20 19:14:24 -06:00
|
|
|
file(GLOB_RECURSE LIB_SOURCES src/*.cpp)
|
|
|
|
file(GLOB_RECURSE LIB_HEADERS src/*.h)
|
|
|
|
files_to_dirs(LIB_HEADERS LIB_INCLUDE_DIRS)
|
|
|
|
|
|
|
|
#Remove test executable from library
|
2022-08-24 21:56:35 -05:00
|
|
|
list(REMOVE_ITEM LIB_SOURCES ${EXEC_SOURCES})
|
2020-01-20 19:14:24 -06:00
|
|
|
|
|
|
|
#Create the library
|
2020-01-21 21:46:24 -06:00
|
|
|
add_library(libopenfpgashell STATIC
|
2020-01-20 19:14:24 -06:00
|
|
|
${LIB_HEADERS}
|
|
|
|
${LIB_SOURCES})
|
2020-01-21 21:46:24 -06:00
|
|
|
target_include_directories(libopenfpgashell PUBLIC ${LIB_INCLUDE_DIRS})
|
|
|
|
set_target_properties(libopenfpgashell PROPERTIES PREFIX "") #Avoid extra 'lib' prefix
|
2020-01-20 19:14:24 -06:00
|
|
|
|
|
|
|
#Specify link-time dependancies
|
2020-01-21 21:46:24 -06:00
|
|
|
target_link_libraries(libopenfpgashell
|
|
|
|
libopenfpgautil
|
2020-01-21 23:59:53 -06:00
|
|
|
libvtrutil
|
|
|
|
readline)
|
2020-01-20 19:14:24 -06:00
|
|
|
|
2022-08-24 21:56:35 -05:00
|
|
|
# Create the test executable
|
|
|
|
foreach(testsourcefile ${EXEC_SOURCES})
|
|
|
|
# Use a simple string replace, to cut off .cpp.
|
|
|
|
get_filename_component(testname ${testsourcefile} NAME_WE)
|
|
|
|
add_executable(${testname} ${testsourcefile})
|
|
|
|
# Make sure the library is linked to each test executable
|
|
|
|
target_link_libraries(${testname} libopenfpgashell)
|
|
|
|
endforeach(testsourcefile ${EXEC_SOURCES})
|
2020-01-20 19:14:24 -06:00
|
|
|
|
2022-08-24 21:47:01 -05:00
|
|
|
install(TARGETS libopenfpgashell DESTINATION bin)
|