Skip to content

Commit

Permalink
Fix windows build fails (Tencent#321)
Browse files Browse the repository at this point in the history
* fix windows build error

* remove wrong commit
  • Loading branch information
tcye authored and nihui committed Mar 30, 2018
1 parent 7334057 commit 3977d32
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 22 deletions.
18 changes: 11 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,21 @@ if(NCNN_OPENMP)
endif()
endif()

add_definitions(-Wall -Wextra -Wno-unused-function)
if(WIN32)
add_definitions(-D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE)
else()
add_definitions(-Wall -Wextra -Wno-unused-function)

add_definitions(-fPIC)
add_definitions(-Ofast)
add_definitions(-fPIC)
add_definitions(-Ofast)

add_definitions(-ffast-math)
# add_definitions(-march=native)
add_definitions(-ffast-math)
# add_definitions(-march=native)

# add_definitions(-flto)
# add_definitions(-flto)

add_definitions(-fvisibility=hidden -fvisibility-inlines-hidden)
add_definitions(-fvisibility=hidden -fvisibility-inlines-hidden)
endif()

if(ANDROID)
# disable shared library on android
Expand Down
16 changes: 8 additions & 8 deletions src/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.

#include "benchmark.h"

#if NCNN_BENCHMARK
#include <stdio.h>
#include "layer/convolution.h"
#endif // NCNN_BENCHMARK

#ifdef _WIN32

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#include <stdint.h> // portable: uint64_t MSVC: __int64
#else // _WIN32
#include <sys/time.h>
#endif // _WIN32

#include "benchmark.h"

#if NCNN_BENCHMARK
#include <stdio.h>
#include "layer/convolution.h"
#endif // NCNN_BENCHMARK


namespace ncnn {

#ifdef _WIN32
Expand Down
4 changes: 4 additions & 0 deletions src/layer/convolutiondepthwise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ int ConvolutionDepthWise::forward(const Mat& bottom_blob, Mat& top_blob) const
const int channels_g = channels / group;
const int num_output_g = num_output / group;

#ifdef _WIN32
#pragma omp parallel for
#else // _WIN32
#pragma omp parallel for collapse(2)
#endif // _WIN32
for (int g=0; g<group; g++)
{
for (int p=0; p<num_output_g; p++)
Expand Down
16 changes: 9 additions & 7 deletions tools/caffe/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@

find_package(Protobuf REQUIRED)

include_directories(${PROTOBUF_INCLUDE_DIR})
if(PROTOBUF_FOUND)
include_directories(${PROTOBUF_INCLUDE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
protobuf_generate_cpp(CAFFE_PROTO_SRCS CAFFE_PROTO_HDRS caffe.proto)
add_executable(caffe2ncnn caffe2ncnn.cpp ${CAFFE_PROTO_SRCS} ${CAFFE_PROTO_HDRS})
target_link_libraries(caffe2ncnn ${PROTOBUF_LIBRARIES})
else()
MESSAGE(WARNING "Protobuf not found, caffe model convert tools won't build")
endif()

include_directories(${CMAKE_CURRENT_BINARY_DIR})
protobuf_generate_cpp(CAFFE_PROTO_SRCS CAFFE_PROTO_HDRS caffe.proto)

add_executable(caffe2ncnn caffe2ncnn.cpp ${CAFFE_PROTO_SRCS} ${CAFFE_PROTO_HDRS})

target_link_libraries(caffe2ncnn ${PROTOBUF_LIBRARIES})

0 comments on commit 3977d32

Please sign in to comment.