cmake_minimum_required(VERSION 3.9) project("libpcf") # For CSV reader if(CSV_CXX_STANDARD) set(CMAKE_CXX_STANDARD ${CSV_CXX_STANDARD}) else() set(CMAKE_CXX_STANDARD 17) endif(CSV_CXX_STANDARD) option(BUILD_PYTHON "Build Python Binding" OFF) message("Building CSV library using C++${CMAKE_CXX_STANDARD}") # Defines CSV_HAS_CXX17 in compatibility.hpp if (CMAKE_VERSION VERSION_LESS "3.12.0") add_definitions(-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}) else() add_compile_definitions(CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}) endif() file(GLOB_RECURSE EXEC_SOURCES test/*.cpp) 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 list(REMOVE_ITEM LIB_SOURCES ${EXEC_SOURCES}) #Create the library add_library(libpcf STATIC ${LIB_HEADERS} ${LIB_SOURCES}) target_include_directories(libpcf PUBLIC ${LIB_INCLUDE_DIRS}) set_target_properties(libpcf PROPERTIES PREFIX "") #Avoid extra 'lib' prefix #Specify link-time dependancies target_link_libraries(libpcf libopenfpgautil libarchfpga libarchopenfpga libvtrutil libpugixml libpugiutil) #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} libpcf) endforeach(testsourcefile ${EXEC_SOURCES})