Fix install dir and warning on MSVC

This commit is contained in:
Naiyang Lin 2022-08-30 20:00:35 +08:00
parent 05c84a4edf
commit 4ae9094772
2 changed files with 15 additions and 25 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
/_build
/amalgamation
/bin
/build-cmake/

View File

@ -48,6 +48,9 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin)
if(INSTALL_PROJECT)
include(GNUInstallDirs)
if(MSVC)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install")
endif()
endif()
if(BUILD_HEADER_ONLY)
@ -229,33 +232,19 @@ if(INSTALL_PROJECT)
endif()
if(BUILD_EXAMPLES)
set(EXAMPLE1_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/examples/example1.c")
set(EXAMPLE2_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/examples/example2.c")
set(EXAMPLE3_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/examples/example3.c")
set(EXAMPLE4_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/examples/example4.c")
set(EXAMPLE5_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/examples/example5.c")
set(EXAMPLE6_SRC_LIST "${CMAKE_CURRENT_SOURCE_DIR}/examples/example6.c")
set(MINIZ_TESTER_SRC_LIST
"${CMAKE_CURRENT_SOURCE_DIR}/tests/miniz_tester.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/tests/timer.cpp")
add_executable(example1 ${EXAMPLE1_SRC_LIST})
target_link_libraries(example1 miniz)
add_executable(example2 ${EXAMPLE2_SRC_LIST})
target_link_libraries(example2 miniz)
add_executable(example3 ${EXAMPLE3_SRC_LIST})
target_link_libraries(example3 miniz)
add_executable(example4 ${EXAMPLE4_SRC_LIST})
target_link_libraries(example4 miniz)
add_executable(example5 ${EXAMPLE5_SRC_LIST})
target_link_libraries(example5 miniz)
add_executable(example6 ${EXAMPLE6_SRC_LIST})
target_link_libraries(example6 miniz)
if(${UNIX})
foreach(X example1 example2 example3 example4 example5 example6)
add_executable(${X} "examples/${X}.c")
target_link_libraries(${X} miniz)
if(MSVC)
# warning C4996: This function or variable may be unsafe. To disable deprecation, use _CRT_SECURE_NO_WARNINGS.
target_compile_definitions(${X} PRIVATE _CRT_SECURE_NO_WARNINGS)
endif()
endforeach(X)
if(UNIX)
target_link_libraries(example6 m)
endif()
# add_executable(miniz_tester ${MINIZ_TESTER_SRC_LIST})
# add_executable(miniz_tester tests/miniz_tester.cpp tests/timer.cpp)
# target_link_libraries(miniz_tester miniz)
endif(BUILD_EXAMPLES)