cnr-isti-vclab / corto

Mesh compression library, designed for rendering and speed.
Other
196 stars 43 forks source link

partition code #3

Open cdcseacave opened 7 years ago

cdcseacave commented 7 years ago

Great project! I only have a small suggestion regarding the project structure. Since it can be used as a library too, it would be helpful to separate the app from the library code. This will not only make the code more clear, but it will make writing the CMake scripts much easier too. Bellow is a sample for the library CMake script:

# Find required packages
FIND_PACKAGE(<package>)
if(<package>_FOUND)
    include_directories(${<package>_INCLUDE_DIRS})
    add_definitions(${<package>_DEFINITIONS})
    link_directories(${<package>_LIBRARY_DIRS})
endif()

# List sources files
FILE(GLOB LIBRARY_FILES_C "*.cpp")
FILE(GLOB LIBRARY_FILES_H "*.h" "*.inl")

# Create library
add_library(libcorto "Libs" "" "${cxx_default}" ${LIBRARY_FILES_C} ${LIBRARY_FILES_H})

# Link its dependencies
TARGET_LINK_LIBRARIES(libcorto ${<package>_LIBS})

# Install
SET_TARGET_PROPERTIES(libcorto PROPERTIES
    PUBLIC_HEADER "${LIBRARY_FILES_H}")
INSTALL(TARGETS libcorto
    EXPORT cortoTargets
    RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT bin
    LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT shlib
    ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" COMPONENT lib
    PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}/corto" COMPONENT dev)