Commit 2eb1844990609fdf1c7d4c66e4f5a1dd397cd816

Scott J. Goldman 2012-05-26T18:20:33

Refactor CMakeLists.txt for mingw cross-compile Two things: 1) By default, Linux CMake puts -fPIC on the link line. So we remove that for MINGW to avoid warnings that it will be ignored. 2) Similarly, move -fvisibility=hidden flag to be for non-mingw compilation only to avoid warnings that it will be ignored.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 165baba..8018ea7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -71,10 +71,12 @@ IF (MSVC)
 
    # Precompiled headers
 ELSE ()
-	SET(CMAKE_C_FLAGS "-O2 -g -D_GNU_SOURCE -fvisibility=hidden -Wall -Wextra -Wno-missing-field-initializers -Wstrict-aliasing=2 -Wstrict-prototypes -Wmissing-prototypes ${CMAKE_C_FLAGS}")
+	SET(CMAKE_C_FLAGS "-O2 -g -D_GNU_SOURCE -Wall -Wextra -Wno-missing-field-initializers -Wstrict-aliasing=2 -Wstrict-prototypes -Wmissing-prototypes ${CMAKE_C_FLAGS}")
 	SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
-	IF (NOT MINGW) # MinGW always does PIC and complains if we tell it to
-		SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
+	IF (MINGW) # MinGW always does PIC and complains if we tell it to
+		STRING(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
+	ELSE ()
+		SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -fPIC")
 	ENDIF ()
 	IF (PROFILE)
 		SET(CMAKE_C_FLAGS "-pg ${CMAKE_C_FLAGS}")