Good afternoon.

We are using CMake to build an open source project. We would like to build it 
on Windows. For that purpose, we use MingW.
However, we have trouble linking three libraries :

  *   libstdc++-6.dll
  *   libwinpthread-1.dll
  *   libgcc_s_seh-1.dll
To solve this, we decided to link all three statically. In order to do so, we 
added the following to our main CMakeLists.txt [1]:

    set(CMAKE_CXX_STANDARD_LIBRARIES "-static-libgcc -static-libstdc++ 
-lwsock32 -lws2_32 ${CMAKE_CSS_STANDARD_LIBRARIES}")
    set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} 
-Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive")

Is this the correct way to proceed in CMake ? Are these the right variables and 
flags to set ? Do we have to use two different cmake variables to achieve our 
goal ?

Any hints on improving this CMakeLists.txt is welcome.
Thanks.

Andres.

[1]: 
https://github.com/azarzadavila/mozart2/blob/d086c4b560472a29a7312e4f291bbc5b3a423414/CMakeLists.txt#L41-L63
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake

Reply via email to