0

I would like to create a self contained project that can generate makefiles, and compile itself. I am using CMake to generate the make files, and MingGW (G++) to compile. It doesn't seem as though CMake was designed to be portable, but I could have done things very incorrectly.

In order to make these programs portable, I merely copied the program folders for both MinGW and CMake to my project. I then use the GUI to point the CMAKE_CXX_COMPILER to the mingw32-g++.exe in the project and the CMAKE_C_COMPILER to mingw32-gcc, and the CMAKE_MAKE_PROGRAM to the mingw32-make.exe.

When I try to hit configure, it says that cc1.exe, and cc1plus.exe is not able to find libmpfr-6.dll, libgmp-10.dll, libmpc-3.dll, etc. All of these files are located in the same folder as the CMAKE_CXX_COMPILER. It seems as though it assumes the needed programs are installed in the system, and that the path to them is defined.

Is there a way to tell CMake where all of these programs are installed? Also if there is any other configuration that needs to be done to make CMake portable.

Have I done anything wrong, and are there better tools to use instead of CMAKE/MinGW.

CMAKE FILE:

cmake_minimum_required(VERSION 3.17)

# set the project name
project(BSharpInterpretter VERSION 1.0)

#configure file for version info
configure_file(BSharpInterpretter_Config.h.in BSharpInterpretter_Config.h)

#add include directories
target_include_directories(BSharpInterpetter PUBLIC
                            "${PROJECT_BINARY_DIR}")

#specify C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

#specify compiler location
#set(rootDir ..\\..)
#set(CMAKE_CXX_COMPILER ${rootDir}\\MingGW\\g++)

# add the executable
add_executable(BSharpInterpetter BSharpInterpretter.cpp)

Other Programs

MinGW with the mingw32-gcc-g++-bin, and mingw32-make-bin packages

Donut
  • 59
  • 1
  • 7
  • It suggests using environment variables, which I would like to avoid since it will not be in a single environment. But if this is the only way, then I will deal with that. – Donut Apr 21 '20 at 21:37
  • 1
    There are several ways to set a specific MinGW as the compiler. There are more solutions suggested [here](https://stackoverflow.com/a/50494125/3987854). Perhaps, the best option for you is to use the `cmake` command line arguments with the `-D` flag to set the various compiler-specific variables. – Kevin Apr 21 '20 at 21:48
  • That sounds exactly what I want. Could you make that a post, so I can accept? Or should we close this question? – Donut Apr 21 '20 at 21:49
  • 1
    The last post I linked already has a couple examples. They are specific to GCC but the same concept applies. Hope that helps! – Kevin Apr 21 '20 at 22:06

0 Answers0