diff --git a/CMakeLists.txt b/CMakeLists.txt index 7aac29b9a50..71e4cc2c682 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,12 +112,12 @@ configure_file(${Ginkgo_SOURCE_DIR}/include/ginkgo/config.hpp.in # This is modified from https://gitlab.kitware.com/cmake/community/wikis/FAQ#dynamic-replace if(MSVC) if(BUILD_SHARED_LIBS) - ginkgo_turn_to_windows_dynamic("CXX") - ginkgo_turn_to_windows_dynamic("C") + ginkgo_switch_to_windows_dynamic("CXX") + ginkgo_switch_to_windows_dynamic("C") set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) else() - ginkgo_turn_to_windows_static("CXX") - ginkgo_turn_to_windows_static("C") + ginkgo_switch_to_windows_static("CXX") + ginkgo_switch_to_windows_static("C") set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS FALSE) endif() endif() @@ -128,6 +128,7 @@ ginkgo_find_package(GTest "GTest::GTest;GTest::Main" FALSE 1.8.1) ginkgo_find_package(gflags gflags FALSE 2.2.2) ginkgo_find_package(RapidJSON rapidjson TRUE 1.1.0) add_subdirectory(third_party) # Third-party tools and libraries + # Needs to be first in order for `CMAKE_CUDA_DEVICE_LINK_EXECUTABLE` to be # propagated to the other parts of Ginkgo in case of building as static libraries if(GINKGO_BUILD_CUDA) diff --git a/INSTALL.md b/INSTALL.md index cc877ca63e5..7ba95897206 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -8,6 +8,10 @@ Use the standard cmake build procedure: mkdir build; cd build cmake -G "Unix Makefiles" [OPTIONS] .. && make ``` +Use `cmake --build .` in some systems like MinGW or Microsoft Visual Studio which do not use `make`. + +For Microsoft Visual Studio, use `cmake --build . --config ` to decide the build type. The possible options are `Debug`, `Release`, `RelWithDebInfo` and `MinSizeRel`. + Replace `[OPTIONS]` with desired cmake options for your build. Ginkgo adds the following additional switches to control what is being built: @@ -82,12 +86,12 @@ Ginkgo adds the following additional switches to control what is being built: [`ARCHITECTURES` specification list](https://github.com/ginkgo-project/CudaArchitectureSelector/blob/master/CudaArchitectureSelector.cmake#L58) section in the documentation of the CudaArchitectureSelector CMake module. * `-DGINKGO_WINDOWS_SHARED_LIBRARY_RELPATH=` where is a relative - path with `PROJECT_BINARY_DIR`. Users must to add the absoulte path + path built with `PROJECT_BINARY_DIR`. Users must add the absolute path (`PROJECT_BINARY_DIR`/`GINKGO_WINDOWS_SHARED_LIBRARY_RELPATH`) into the environment variable PATH when building shared libraries and executable program, default is `windows_shared_library`. -* `-DGINKGO_CHECK_PATH={ON, OFF}` checks the environment variable PATH is valid. - It is valid only when building shared libraries and executable program, +* `-DGINKGO_CHECK_PATH={ON, OFF}` checks if the environment variable PATH is valid. + It is checked only when building shared libraries and executable program, default is `ON` For example, to build everything (in debug mode), use: diff --git a/cmake/build_helpers.cmake b/cmake/build_helpers.cmake index 8641a85a4a5..76125a761a6 100644 --- a/cmake/build_helpers.cmake +++ b/cmake/build_helpers.cmake @@ -73,7 +73,7 @@ function(ginkgo_check_shared_library name) endif() endfunction() -function(ginkgo_turn_windows_link lang from to) +function(ginkgo_switch_windows_link lang from to) foreach(flag_var "CMAKE_${lang}_FLAGS" "CMAKE_${lang}_FLAGS_DEBUG" "CMAKE_${lang}_FLAGS_RELEASE" "CMAKE_${lang}_FLAGS_MINSIZEREL" "CMAKE_${lang}_FLAGS_RELWITHDEBINFO" @@ -88,10 +88,10 @@ function(ginkgo_turn_windows_link lang from to) endforeach() endfunction() -macro(ginkgo_turn_to_windows_static lang) - ginkgo_turn_windows_link(${lang} "MD" "MT") +macro(ginkgo_switch_to_windows_static lang) + ginkgo_switch_windows_link(${lang} "MD" "MT") endmacro() -macro(ginkgo_turn_to_windows_dynamic lang) - ginkgo_turn_windows_link(${lang} "MT" "MD") +macro(ginkgo_switch_to_windows_dynamic lang) + ginkgo_switch_windows_link(${lang} "MT" "MD") endmacro() \ No newline at end of file diff --git a/cmake/package_helpers.cmake b/cmake/package_helpers.cmake index 67414aa48b1..74208b86e09 100644 --- a/cmake/package_helpers.cmake +++ b/cmake/package_helpers.cmake @@ -119,9 +119,7 @@ macro(ginkgo_add_external_target new_target external_name includedir libdir buil # Since we do not really manage other build types, let's globally use the DEBUG symbols if(MSVC) # Only Debug build uses MDd or MTd, and others use MD or MT. - # MSVC would like to use same runtime library, so we use Debug third-party in Debug and Release third-party in Release. - set_target_properties(${new_target} PROPERTIES IMPORTED_LOCATION_DEBUG - ${${external_name}_LIBRARY_DEBUG}) + # MSVC would like to use same runtime library, so we use Debug third-party in Debug and Release third-party in others. set_target_properties(${new_target} PROPERTIES IMPORTED_LOCATION ${${external_name}_LIBRARY_RELEASE}) else() diff --git a/cuda/CMakeLists.txt b/cuda/CMakeLists.txt index f5e6515897b..8ad05f58386 100644 --- a/cuda/CMakeLists.txt +++ b/cuda/CMakeLists.txt @@ -17,9 +17,9 @@ endif() # This is modified from https://gitlab.kitware.com/cmake/community/wikis/FAQ#dynamic-replace if(MSVC) if(BUILD_SHARED_LIBS) - ginkgo_turn_to_windows_dynamic("CUDA") + ginkgo_switch_to_windows_dynamic("CUDA") else() - ginkgo_turn_to_windows_static("CUDA") + ginkgo_switch_to_windows_static("CUDA") endif() endif()