Skip to content

Commit

Permalink
Fixed cmake to build lib correctly named
Browse files Browse the repository at this point in the history
  • Loading branch information
janjurca committed Nov 23, 2023
1 parent f299991 commit f625a17
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/
# ---- Create library ----
# add_library(Filestorm ${headers} ${sources}) Note: for header-only libraries change all PUBLIC
# flags to INTERFACE and create an interface target: add_library(${PROJECT_NAME} INTERFACE)
add_library(lib${PROJECT_NAME} ${headers} ${sources})
set_target_properties(lib${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)
add_library(${PROJECT_NAME} ${headers} ${sources})
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)

# being a cross-platform target, we enforce standards conformance on MSVC
target_compile_options(lib${PROJECT_NAME} PUBLIC "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive->")
target_compile_options(${PROJECT_NAME} PUBLIC "$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/permissive->")

# Link dependencies
target_link_libraries(lib${PROJECT_NAME} PRIVATE fmt::fmt)
target_link_libraries(${PROJECT_NAME} PRIVATE fmt::fmt)

target_include_directories(
lib${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
)

# ---- Create an installable target ----
Expand All @@ -76,7 +76,7 @@ target_include_directories(
string(TOLOWER ${PROJECT_NAME}/version.h VERSION_HEADER_LOCATION)

packageProject(
NAME lib${PROJECT_NAME}
NAME ${PROJECT_NAME}
VERSION ${PROJECT_VERSION}
NAMESPACE ${PROJECT_NAME}
BINARY_DIR ${PROJECT_BINARY_DIR}
Expand All @@ -89,7 +89,7 @@ packageProject(

file(GLOB standalone_sources CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/standalone/source/*.cpp)

add_executable(${PROJECT_NAME} ${standalone_sources})
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17 OUTPUT_NAME "Filestorm")
add_executable(${PROJECT_NAME}Executable ${standalone_sources})
set_target_properties(${PROJECT_NAME}Executable PROPERTIES CXX_STANDARD 17 OUTPUT_NAME "Filestorm")

target_link_libraries(${PROJECT_NAME} lib${PROJECT_NAME} cxxopts fmt::fmt spdlog)
target_link_libraries(${PROJECT_NAME}Executable ${PROJECT_NAME} cxxopts fmt::fmt spdlog)
2 changes: 1 addition & 1 deletion standalone/source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ auto main(int argc, char** argv) -> int {
}

if (result["version"].as<bool>()) {
std::cout << LIBFILESTORM_VERSION << std::endl;
std::cout << FILESTORM_VERSION << std::endl;
return 0;
}

Expand Down

0 comments on commit f625a17

Please sign in to comment.