From de6309eca26992b01c3343fad35535a730b52718 Mon Sep 17 00:00:00 2001 From: Jacker Date: Wed, 31 Jan 2024 22:44:11 +0200 Subject: [PATCH] cmake can go fPIC itself --- CMakeLists.txt | 3 ++- glew/CMakeLists.txt | 22 +++++++++++----------- sqlite3/CMakeLists.txt | 8 ++++---- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56bff255..c1296e35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,8 @@ set(LIBS_BINARY_DIR ${PROJECT_BINARY_DIR}/libs) set(LIBS_DOWNLOAD_DIR ${PROJECT_BINARY_DIR}/downloads/pgk) set(LIBS_DOWNLOAD_SRC_DIR ${PROJECT_BINARY_DIR}/downloads/src) -if (UNIX) +# keep this check in sync with the external libs build commands +if (UNIX AND (BUNDLED_OGG_VORBIS OR BUNDLED_OPENAL OR BUNDLED_LUA)) find_program(MAKE NAMES gmake make mingw32-make REQUIRED) endif() diff --git a/glew/CMakeLists.txt b/glew/CMakeLists.txt index f84c6871..6f46a61d 100644 --- a/glew/CMakeLists.txt +++ b/glew/CMakeLists.txt @@ -3,17 +3,6 @@ cmake_minimum_required(VERSION 3.10.3) #project(glew) -if(MINGW OR UNIX) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-attributes") - - # this is required for bundled 64bit glew lib - # http://stackoverflow.com/questions/7216244/why-is-fpic-absolutely-necessary-on-64-and-not-on-32bit-platforms - # note: -mcmodel=large might be an option to set too - if(NOT CROSS_COMPILE32) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") - endif(NOT CROSS_COMPILE32) -endif() - set(GLEW_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}) source_group(API FILES ${API}) @@ -27,6 +16,17 @@ target_include_directories(bundled_glew PUBLIC ${GLEW_SOURCE_DIR}/include) target_compile_definitions(bundled_glew PUBLIC GLEW_STATIC) set_target_properties(bundled_glew PROPERTIES LINKER_LANGUAGE C) +if(MINGW OR UNIX) + target_compile_options(bundled_glew PRIVATE "-Wno-attributes") + + # this is required for bundled 64bit glew lib + # http://stackoverflow.com/questions/7216244/why-is-fpic-absolutely-necessary-on-64-and-not-on-32bit-platforms + # note: -mcmodel=large might be an option to set too + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set_target_properties(bundled_glew PROPERTIES POSITION_INDEPENDENT_CODE ON) + endif() +endif() + #install(TARGETS glew # LIBRARY DESTINATION "${GLEW_SOURCE_DIR}/lib/" # ARCHIVE DESTINATION "${GLEW_SOURCE_DIR}/lib/" diff --git a/sqlite3/CMakeLists.txt b/sqlite3/CMakeLists.txt index d6fc7f52..f041d023 100644 --- a/sqlite3/CMakeLists.txt +++ b/sqlite3/CMakeLists.txt @@ -67,8 +67,8 @@ if(MINGW OR UNIX) # http://stackoverflow.com/questions/7216244/why-is-fpic-absolutely-necessary-on-64-and-not-on-32bit-platforms if(NOT CROSS_COMPILE32) # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") - # target_compile_options(sqlite_int INTERFACE "-fPIC") - set_target_properties(sqlite_int PROPERTIES POSITION_INDEPENDENT_CODE ON) + target_compile_options(sqlite_int INTERFACE "-fPIC") + # set_target_properties(sqlite_int PROPERTIES POSITION_INDEPENDENT_CODE ON) endif(NOT CROSS_COMPILE32) endif() @@ -110,7 +110,7 @@ endif() if (SQLITE_BUILD_STATIC) # build static library add_library(${SQLITE_STATIC_NAME} STATIC ${SRC_LIB_FILE}) - target_link_libraries(${SQLITE_STATIC_NAME} PUBLIC sqlite_int) + target_link_libraries(${SQLITE_STATIC_NAME} PRIVATE sqlite_int) endif() if (SQLITE_BUILD_SHARED) @@ -120,7 +120,7 @@ if (SQLITE_BUILD_SHARED) #then we do dll library, so need to export api set_target_properties(${SQLITE_DYN_NAME} PROPERTIES DEFINE_SYMBOL "SQLITE_API=__declspec(dllexport)") endif() - target_link_libraries(${SQLITE_DYN_NAME} PUBLIC sqlite_int) + target_link_libraries(${SQLITE_DYN_NAME} PRIVATE sqlite_int) endif() #install(TARGETS ${TO_INSTALL}