diff --git a/dlib/cmake b/dlib/cmake index 33c2edfc3..e13d04cca 100644 --- a/dlib/cmake +++ b/dlib/cmake @@ -78,6 +78,12 @@ elseif (MSVC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") # else if using Visu message(STATUS "Enabling SSE2 instructions") add_definitions(-DDLIB_HAVE_SSE2) endif() + + # By default Visual Studio does not support .obj files with more than 65k sections + # Code generated by file_to_code_ex and code using DNN module can have them + # this flag enables > 65k sections, but produces .obj files that will not be readable by + # VS 2005 + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj") endif() diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 5b6cf40a1..153fe6b0e 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -10,10 +10,6 @@ PROJECT(examples) include(../dlib/cmake) -if (POLICY CMP0054) - cmake_policy(SET CMP0054 NEW) -endif() - # Tell CMake to compile a program. We do this with the ADD_EXECUTABLE() # statement which takes the name of the output executable and then a list of # .cpp files to compile. Here each example consists of only one .cpp file but @@ -35,13 +31,6 @@ ENDMACRO() # The deep learning toolkit requires a C++11 capable compiler. if (COMPILER_CAN_DO_CPP_11) - # Visual Studio Specific - # DNN module produces long type names for NN definitions - disable this warning for MSVC - # And when compiling Debug mode file will be too big for normal compilation - if (MSVC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - message(STATUS "Enabling Visual Studio specific flags for DNN") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4503 /bigobj") - endif() add_example(dnn_mnist_ex) add_example(dnn_mnist_advanced_ex) add_example(dnn_inception_ex) diff --git a/examples/dnn_inception_ex.cpp b/examples/dnn_inception_ex.cpp index f3f2bfd14..0fa92e4f0 100644 --- a/examples/dnn_inception_ex.cpp +++ b/examples/dnn_inception_ex.cpp @@ -23,10 +23,17 @@ the IEEE Conference on Computer Vision and Pattern Recognition. 2015. */ +// DNN module uses template-based network declaration that leads to very long +// type names. Visual Studio will produce Warning C4503 in such cases +#ifdef _MSC_VER +# pragma warning( disable: 4503 ) +#endif #include + #include #include + using namespace std; using namespace dlib; @@ -84,7 +91,7 @@ int main(int argc, char** argv) try // Make an instance of our inception network. net_type net; cout << "The net has " << net.num_layers << " layers in it." << endl; - cout << net << endl; +// cout << net << endl; cout << "Traning NN..." << endl; diff --git a/examples/dnn_mnist_advanced_ex.cpp b/examples/dnn_mnist_advanced_ex.cpp index 4da911b4f..ab9527a25 100644 --- a/examples/dnn_mnist_advanced_ex.cpp +++ b/examples/dnn_mnist_advanced_ex.cpp @@ -10,6 +10,11 @@ - Accessing and configuring layers in a network */ +// DNN module uses template-based network declaration that leads to very long +// type names. Visual Studio will produce Warning C4503 in such cases +#ifdef _MSC_VER +# pragma warning( disable: 4503 ) +#endif #include #include