Re: [hatari-devel] Small CMAKE diff

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


On Thu, Jan 24, 2019 at 6:08 PM Thorsten Otto <admin@xxxxxxxxxxx> wrote:
On Donnerstag, 24. Januar 2019 17:01:56 CET Christer Solskogen wrote:
> Oh, but I got it to work.  With the diff applied :-)

Then maybe cmake knows about that compiler, and looks in the right places. It
is still a total nogo to try to be more clever as the compiler, and
replicating all the builtin pathnames for hundreds of compilers in the rules.
The compiler knows where to look for libraries, cmake should not mess with
that.

I stumbled upon this when trying to cross-compile libraries with the m68k-
atari-mint toolchain, for different processor types. In the end i had to
install rule files for 3 different compilers, hacking in the correct
pathnames, although it is only one.


This is the toolchain file I'm using, and it seems to do the trick.

# mingw32 versions of the different tools
# (change these depending on your system settings)
set (MINGW_EXE_PREFIX "x86_64-w64-mingw32")
set (MINGW_ROOT_PATH "mingw")
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)


#-- Changes should not be required below this point

# The name of the target operating system
SET(CMAKE_SYSTEM_NAME Windows)

# Use the value provided to set mingw's tools
SET(CMAKE_C_COMPILER ${MINGW_EXE_PREFIX}-gcc )
SET(CMAKE_CXX_COMPILER ${MINGW_EXE_PREFIX}-g++)
SET(CMAKE_RC_COMPILER ${MINGW_EXE_PREFIX}-windres)

SET(CMAKE_RC_FLAGS "-F pe-i386")
add_compile_options("-m32")
SET(CMAKE_EXE_LINKER_FLAGS "-m32 -Wl,-mi386pe")

# Base directory for the target environment
# We use the output from '-print-sysroot'
EXECUTE_PROCESS(
   COMMAND ${CMAKE_C_COMPILER} -print-sysroot
   OUTPUT_VARIABLE CMAKE_FIND_ROOT_PATH
   OUTPUT_STRIP_TRAILING_WHITESPACE
)
# bin/, include/, lib/ and share/ are often in "mingw/"
# You might need to adjust the path for your system
SET(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH}/${MINGW_ROOT_PATH})

# Make the path absolute, a relative path could confuse some systems
get_filename_component ( CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ABSOLUTE )

#message ( "MINGW_ROOT_PATH ${MINGW_ROOT_PATH} MINGW_EXE_PREFIX ${MINGW_EXE_PREFIX} CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH}" )

# FindSDL.cmake doesn't search correctly in CMAKE_FIND_ROOT_PATH
# so we force SDLDIR here
set ( ENV{SDLDIR} ${CMAKE_FIND_ROOT_PATH}/include/SDL )

# Adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/