Skip to content

Commit

Permalink
Improve CMake & vcxproj files & fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
visuve committed Apr 13, 2024
1 parent 3511adf commit 03ce5ed
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
out/
.vs/
packages/
*.user
*.user
CMake*.json
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@ set(LIBRARY_OUTPUT_PATH "..")
if(MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
add_compile_options(/MP /W4 /WX)
add_compile_definitions(NOMINMAX VC_EXTRALEAN)
endif()

# apt install libicu-dev / dnf install icu
find_package(ICU COMPONENTS i18n uc REQUIRED)

message(${ICU_INCLUDE_DIRS})
message(${ICU_INCLUDE_DIR})

add_subdirectory("PystykorvaLib")
include_directories("PystykorvaLib")
Expand Down
15 changes: 12 additions & 3 deletions PystykorvaCLI/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
file(GLOB SourceFiles "*.cpp")

add_executable("pystykorva" ${SourceFiles})
target_precompile_headers("pystykorva" PRIVATE "PCH.hpp")
target_link_libraries("pystykorva" LINK_PRIVATE libpystykorva ICU::uc)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(ExecutableName "Pystykorva")
set(LibraryName "LibPystykorva")
else()
set(ExecutableName "pystykorva")
set(LibraryName "libpystykorva")
endif()

add_executable(${ExecutableName} ${SourceFiles})
target_precompile_headers(${ExecutableName} PRIVATE "PCH.hpp")
target_link_libraries(${ExecutableName} LINK_PRIVATE ${LibraryName} ICU::uc)

2 changes: 1 addition & 1 deletion PystykorvaCLI/PystykorvaCLI.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{4D16FDA1-E2D7-4F93-9542-56F45C743A34}</ProjectGuid>
<ConfigurationType>Application</ConfigurationType>
<ProjectName>PystykorvaCLI</ProjectName>
<ProjectName>Pystykorva</ProjectName>
</PropertyGroup>
<Import Project="$(SolutionDir)\Pystykorva.props" />
<ItemDefinitionGroup>
Expand Down
11 changes: 8 additions & 3 deletions PystykorvaLib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
file(GLOB SourceFiles "*.cpp")

add_library("libpystykorva" STATIC ${SourceFiles})
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(LibraryName "LibPystykorva")
else()
set(LibraryName "libpystykorva")
endif()

target_precompile_headers("libpystykorva" PRIVATE "PCH.hpp")
add_library(${LibraryName} STATIC ${SourceFiles})
target_precompile_headers(${LibraryName} PRIVATE "PCH.hpp")
target_link_libraries(${LibraryName} LINK_PUBLIC ICU::i18n ICU::uc)

target_link_libraries("libpystykorva" LINK_PUBLIC ICU::i18n ICU::uc)
2 changes: 1 addition & 1 deletion PystykorvaLib/PystykorvaLib.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup Label="Globals">
<ProjectGuid>{7FA20915-6EFB-40AC-969C-1D408922AFC3}</ProjectGuid>
<ConfigurationType>StaticLibrary</ConfigurationType>
<ProjectName>PystykorvaLib</ProjectName>
<ProjectName>LibPystykorva</ProjectName>
</PropertyGroup>
<Import Project="$(SolutionDir)\Pystykorva.props" />
<ItemDefinitionGroup>
Expand Down
20 changes: 13 additions & 7 deletions PystykorvaTests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
file(GLOB SourceFiles "*.cpp")
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
file(GLOB SourceFiles "*.cpp" "Win32/*.cpp")
set(ExecutableName "PystykorvaTests")
set(LibraryName "LibPystykorva")
else()
file(GLOB SourceFiles "*.cpp")
set(ExecutableName "pystykorva_tests")
set(LibraryName "libpystykorva")
endif()

add_executable("pystykorva_tests" ${SourceFiles})

add_test(NAME "pystykorva_tests" COMMAND $<TARGET_FILE:PystykorvaTests>)

# target_precompile_headers("pystykorva_tests" PRIVATE "PCH.hpp")
target_link_libraries("pystykorva_tests" LINK_PRIVATE libpystykorva gtest)
add_executable(${ExecutableName} ${SourceFiles})
add_test(NAME ${ExecutableName} COMMAND $<TARGET_FILE:${ExecutableName}>)
target_precompile_headers(${ExecutableName} PRIVATE "PCH.hpp")
target_link_libraries(${ExecutableName} LINK_PRIVATE ${LibraryName} gtest)
3 changes: 2 additions & 1 deletion PystykorvaTests/PystykorvaTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ std::filesystem::path TestDataPath()
return current / "Data";
}

throw std::runtime_error(std::format("Test data not found @ {}", current.string()));
const std::string message = "Test data not found @ " + current.string();
throw std::runtime_error(message);
}

TEST(PystykorvaTests, SearchSuccess)
Expand Down

0 comments on commit 03ce5ed

Please sign in to comment.