Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ message(STATUS "CMAKE_SYSTEM_PROCESSOR = ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "CMAKE_CXX_COMPILER_ID = ${CMAKE_C_COMPILER_ID}")

if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL AMD64)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
message(STATUS "compiling with -march=native")
target_compile_options(despacer PRIVATE -march=native)
elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
message(STATUS "Assuming AVX2, SSE4.2, SSE4.1 support on MSVC")
target_compile_options(despacer PRIVATE /arch:AVX2)
target_compile_definitions(despacer PRIVATE __SSE4_1__ __SSE4_2__ __AVX2__)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the Microsoft documentation:

The __AVX__ preprocessor symbol is defined when the /arch:AVX, /arch:AVX2 or /arch:AVX512 compiler option is specified. The __AVX2__ preprocessor symbol is defined when the /arch:AVX2 or /arch:AVX512 compiler option is specified.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather that the macros starting with _ not be manually set. Let the compiler do it.

endif()
endif()

Expand Down Expand Up @@ -52,5 +56,3 @@ if(BENCHMARKS)
target_compile_features(despacer PRIVATE "c_std_11")
endif()
endif()


5 changes: 3 additions & 2 deletions dub.sdl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ targetName "despacer"
sourcePaths "./bindings/d/src/"
importPaths "./bindings/d/src/"

libs "$PACKAGE_DIR/build/despacer" platform="windows"
libs "$PACKAGE_DIR/build/Release/despacer" platform="windows"
lflags "$PACKAGE_DIR/build/despacer.a" platform="posix"
libs "msvcrt" platform="windows"
lflags "/NODEFAULTLIB:libcmt" "/NODEFAULTLIB:msvcrtd" platform="windows-dmd"
Expand All @@ -19,6 +19,7 @@ dflags "--link-internally" platform="windows-ldc"
// support SIMD
dflags "-mcpu=native"

preBuildCommands "cmake -S ./ -B ./build && cmake --build ./build --config Release"
preBuildCommands "cmake -S ./ -B ./build -DBENCHMARKS=OFF -DUNIT_TESTS=OFF && cmake --build ./build --config Release" platform="posix"
preBuildCommands "cmake -G \"Ninja Multi-Config\" -S ./ -B ./build -DBENCHMARKS=OFF -DUNIT_TESTS=OFF && cmake --build ./build --config Release" platform="windows"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we assuming that Ninja is available and used?


extraDependencyFiles "./CMakeLists.txt" "./include/**/*" "./src/**/*"