Skip to content

Commit

Permalink
Merge pull request zeromq#1245 from diorcety/clang_win32
Browse files Browse the repository at this point in the history
Windows MSVC/Clang improvements
  • Loading branch information
bluca authored Apr 9, 2020
2 parents e969adf + 96f638b commit 5f13e46
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 24 deletions.
26 changes: 16 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ enable_testing()
set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
# Select flags
SET(CMAKE_C_FLAGS_RELEASE "-O3")
if(MSVC)
SET(CMAKE_C_FLAGS_RELEASE "/O2")
else()
SET(CMAKE_C_FLAGS_RELEASE "-O3")
endif()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/Modules)

Expand Down Expand Up @@ -59,15 +63,17 @@ file(WRITE "${PROJECT_BINARY_DIR}/platform.h.in" "

configure_file("${PROJECT_BINARY_DIR}/platform.h.in" "${PROJECT_BINARY_DIR}/platform.h")

#The MSVC C compiler is too out of date,
#so the sources have to be compiled as c++
if (MSVC)
enable_language(CXX)
file(GLOB sources "${SOURCE_DIR}/src/*.c")
set_source_files_properties(
${sources}
PROPERTIES LANGUAGE CXX
)
if (WIN32)
#The MSVC C compiler is too out of date,
#so the sources have to be compiled as c++
if (MSVC AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
enable_language(CXX)
file(GLOB sources "${SOURCE_DIR}/src/*.c")
set_source_files_properties(
${sources}
PROPERTIES LANGUAGE CXX
)
endif()
set(MORE_LIBRARIES ws2_32 Rpcrt4 Iphlpapi)
endif()

Expand Down
34 changes: 20 additions & 14 deletions zproject_cmake.gsl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ enable_testing()
set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
# Select flags
SET(CMAKE_C_FLAGS_RELEASE "-O3")
if(MSVC)
SET(CMAKE_C_FLAGS_RELEASE "/O2")
else()
SET(CMAKE_C_FLAGS_RELEASE "-O3")
endif()

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/builds/cmake/Modules)

Expand Down Expand Up @@ -105,19 +109,21 @@ file(WRITE "${PROJECT_BINARY_DIR}/platform.h.in" "

configure_file("${PROJECT_BINARY_DIR}/platform.h.in" "${PROJECT_BINARY_DIR}/platform.h")

#The MSVC C compiler is too out of date,
#so the sources have to be compiled as c++
if (MSVC)
enable_language(CXX)
. if project.use_cxx
file(GLOB sources "${SOURCE_DIR}/src/*.$(project.source_ext)")
. else
file(GLOB sources "${SOURCE_DIR}/src/*.$(project.source_ext)")
. endif
set_source_files_properties(
${sources}
PROPERTIES LANGUAGE CXX
)
if (WIN32)
#The MSVC C compiler is too out of date,
#so the sources have to be compiled as c++
if (MSVC AND NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
enable_language(CXX)
. if project.use_cxx
file(GLOB sources "${SOURCE_DIR}/src/*.$(project.source_ext)")
. else
file(GLOB sources "${SOURCE_DIR}/src/*.$(project.source_ext)")
. endif
set_source_files_properties(
${sources}
PROPERTIES LANGUAGE CXX
)
endif()
set(MORE_LIBRARIES ws2_32 Rpcrt4 Iphlpapi)
endif()

Expand Down

0 comments on commit 5f13e46

Please sign in to comment.