Could NOT find wxWidgets | CMake issue - c++

so I was trying to link to wxWidgets with CMake, and I couldn't get it to work. Here is my CMakeLists.txt.
cmake_minimum_required(VERSION 3.20.1)
set(CMAKE_CXX_STANDARD 20)
project(FormApplication)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set(EXE_NAME run)
find_package(wxWidgets REQUIRED gl core base OPTIONAL_COMPONENTS net)
include(${wxWidgets_USE_FILE})
add_subdirectory(src) # creates an exe named ${EXE_NAME}
target_link_libraries(${EXE_NAME} PRIVATE ${wxWidgets_LIBRARIES})
I get the following error when running cmake -S . -G "Ninja" -B build
CMake Error at C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find wxWidgets (missing: wxWidgets_LIBRARIES
wxWidgets_INCLUDE_DIRS gl core base)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.20/Modules/FindwxWidgets.cmake:1025 (find_package_handle_standard_args)
CMakeLists.txt:7 (find_package)
Why do I get this error? Every source I go to has a different answer, but none of them have worked so far. Some even say you can't link to wxWidgets with cmake.
Please help, I've been trying to get this to work for a couple days already. Thanks in advance.

Related

CMake error, SDL_mixer could not find libxmp

CMake Error:
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find libxmp (missing: libxmp_LIBRARY libxmp_INCLUDE_PATH)
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
vendor/SDL_mixer/cmake/Findlibxmp.cmake:17 (find_package_handle_standard_args)
vendor/SDL_mixer/CMakeLists.txt:616 (find_package)
My CMakeLists.txt:
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
set(ProjectName SnakeGameSDL)
set(RootSources src/main.cpp src/Map.cpp src/Game.cpp)
set(RootHeaders src/Map.hpp src/Game.hpp)
add_executable(${ProjectName} ${RootSources} ${RootHeaders})
add_subdirectory(src/CSDLContext)
add_subdirectory(src/CAppSettings)
add_subdirectory(src/CollideSystem)
add_subdirectory(src/FontManager)
add_subdirectory(src/Food)
add_subdirectory(src/GameScenes)
add_subdirectory(src/GameScore)
add_subdirectory(src/Observer)
add_subdirectory(src/AchievementSystem)
add_subdirectory(src/Snake)
add_subdirectory(src/SoundManager)
add_subdirectory(src/SpriteAnimation)
add_subdirectory(src/TextureManager)
add_subdirectory(src/Timer)
#Vendor
add_subdirectory(vendor/SDL)
target_link_libraries(${ProjectName} SDL)
add_subdirectory(vendor/SDL_image)
target_link_libraries(${ProjectName} SDL_image)
add_subdirectory(vendor/SDL_ttf)
target_link_libraries(${ProjectName} SDL_ttf)
add_subdirectory(vendor/SDL_mixer)
target_link_libraries(${ProjectName} SDL_mixer)
I have to add in vendor libxmp library and specify path or something like this in SDL_mixer cmake file or its completly wrong?. My target is to build project or there some more easier ways to get what i want?
Not really a fix but for now no error,
i just added this line in my root CMakeLists.txt
set(SDL2MIXER_VENDORED ON CACHE BOOL "" FORCE) <-- this one
add_subdirectory(vendor/SDL_mixer)
target_link_libraries(${ProjectName} SDL_mixer)

CUDA, Boost and Cmake "string sub-command REGEX, mode MATCHALL needs at least 5 arguments total to command."

I want to use CUDA, Boost for my application and find myself stuck with the following error message
$ cmake ..
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/BoostDetectToolset-1.71.0.cmake:5 (string):
string sub-command REGEX, mode MATCHALL needs at least 5 arguments total to
command.
Call Stack (most recent call first):
/usr/lib/x86_64-linux-gnu/cmake/boost_program_options-1.71.0/boost_program_options-config.cmake:24 (include)
/usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:117 (find_package)
/usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:182 (boost_find_component)
/home/long/.local/share/JetBrains/Toolbox/apps/CLion/ch-0/211.7442.42/bin/cmake/linux/share/cmake-3.19/Modules/FindBoost.cmake:460 (find_package)
CMakeLists.txt:7 (find_package)
-- Boost toolset is unknown (compiler )
-- Configuring incomplete, errors occurred!
My CMake file looks like following
cmake_minimum_required(VERSION 3.16)
project(chaotic_attractor CUDA)
set(CMAKE_CUDA_STANDARD 14)
find_package(Boost 1.71.0 REQUIRED COMPONENTS program_options)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(chaotic_attractor strangeattractor/main.cu)
target_link_libraries(chaotic_attractor ${Boost_LIBRARIES})
set_target_properties(
chaotic_attractor
PROPERTIES
CUDA_SEPARABLE_COMPILATION ON)
It is not clear to me if NVCC and Boost can get along. Does anyone have an idea how to solve this problem?
Enabling the CXX language here is apparently a requirement for Boost.
cmake_minimum_required(VERSION 3.16)
project(chaotic_attractor LANGUAGES CXX CUDA)
set(CMAKE_CUDA_STANDARD 14)
...

How to add MPICH library to CLion project?

I downloaded the mpich-3.3.2 archive (stable release) from the official site, unpacked it and concluded that I have the MPICH library. But I can’t add it to Clion. Here is my CMakeLists.txt:
cmake_minimum_required(VERSION 3.15)
project(MyProject)
set(CMAKE_CXX_STANDARD 17)
find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
SET(CMAKE_C_COMPILER mpicc)
SET(CMAKE_CXX_COMPILER mpicxx)
add_executable(MyProject main.cpp)
I tried to enter different things in CMakeLists.txt, but always the same thing:
-- Could NOT find MPI_C (missing: MPI_C_LIB_NAMES MPI_C_HEADER_DIR MPI_C_WORKS)
-- Could NOT find MPI_CXX (missing: MPI_CXX_LIB_NAMES MPI_CXX_HEADER_DIR MPI_CXX_WORKS)
CMake Error at C:/Program Files/JetBrains/CLion 2019.3.4/bin/cmake/win/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find MPI (missing: MPI_C_FOUND MPI_CXX_FOUND)
Call Stack (most recent call first):
C:/Program Files/JetBrains/CLion 2019.3.4/bin/cmake/win/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/JetBrains/CLion 2019.3.4/bin/cmake/win/share/cmake-3.16/Modules/FindMPI.cmake:1700 (find_package_handle_standard_args)
CMakeLists.txt:6 (find_package)
What am I doing wrong? How should Clion find out the location of MPICH on my computer?

Use MPI within CMake in Microsoft Visual Studio

I have a C++ project that is implemented in Linux with JetBrain CLion IDE. To get the executable, I used CMake which is fully matched with JetBrain CLion. The project uses MPI to handle multi-node processing, and the project works fine in Linux.
Now, I have to get an executable for Windows too. So, I installed the community version of Visual Studio 2019 along with Microsft MPI to build my project there too. I found that it might be easier to create the sln file for the project by CMake and then import the project into VS. But, when I tried this approach, I got an error for not finding MPI:
Could NOT find MPI_C (missing: MPI_C_LIB_NAMES MPI_C_HEADER_DIR MPI_C_WORKS)
Could NOT find MPI_CXX (missing: MPI_CXX_LIB_NAMES MPI_CXX_HEADER_DIR MPI_CXX_WORKS)
CMake Error at C:/Program Files/CMake/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find MPI (missing: MPI_C_FOUND MPI_CXX_FOUND)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.15/Modules/FindMPI.cmake:1687 (find_package_handle_standard_args)
CMakeLists.txt:35 (find_package)
The cmake code that works in Linux is:
find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
add_executable(prjt main.cpp)
add_subdirectory(sub1)
add_subdirectory(sub2)
target_link_libraries(prjt ${MPI_LIBRARIES})
set_property(TARGET prjt PROPERTY CXX_STANDARD 11)
After reading [1] and [2], I also tried:
set(CMAKE_PREFIX_PATH "C:/Program Files/Microsoft MPI")
find_package(MPI REQUIRED)
include_directories(${MPI_INCLUDE_PATH})
set(CMAKE_C_FLAGS "${CMAKE_FLAGS} ${MPI_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MPI_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MPI_EXE_LINKER_FLAGS}")
add_executable(prjt main.cpp)
add_subdirectory(sub1)
add_subdirectory(sub2)
target_link_libraries(prjt ${MPI_LIBRARIES})
set_property(TARGET prjt PROPERTY CXX_STANDARD 11)
but still no success.
I also tried to link MPI directly via MSVS, as it is instructed in [3], but it did not work too. The problem within that approach is that when I call set MSMPI, I only get MSMPI_BIN=C:\Program Files\Microsoft MPI\Bin\ and I do not get the rest of the environment variables. In the Linker of MSVS also I manually added the Microst SDK address. (I also added the other required environment variables as [4] explains)
I appreciate any help or comment.

can't add boost to cmake project on cygwin: Imported targets not available for Boost version

I have cygwin in c:\cygwin64 and boost_1_64_0 in /usr/src file. Here is my CMakeLists.txt:
set(BOOST_HOME /usr/src/boost_1_64_0)
set(BOOST_INCLUDEDIR /usr/src/boost_1_64_0/boost)
cmake_minimum_required(VERSION 3.8)
project(spider)
set(CMAKE_CXX_STANDARD 11)
set(SOURCE_FILES main.cpp)
set(THREADS_PREFER_PTHREAD_FLAG ON)
include_directories(boost ${BOOST_HOME})
find_package(Threads REQUIRED)
find_package(Boost 1.64.0 COMPONENTS system filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(spider ${SOURCE_FILES})
target_link_libraries(spider ${Boost_LIBRARIES})
target_link_libraries(spider Threads::Threads)
Clion starts cmake this way:
C:\Users\steve\.CLion2017.2\system\cygwin_cmake\bin\cmake.exe --build C:\Users\steve\Dropbox\Projects\cpp-spider\cmake-build-debug --target spider -- -j 1
I get this error:
CMake Warning at /cygdrive/c/Users/steve/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/FindBoost.cmake:765 (message):
Imported targets not available for Boost version
Call Stack (most recent call first):
/cygdrive/c/Users/steve/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/FindBoost.cmake:869 (_Boost_COMPONENT_DEPENDENCIES)
/cygdrive/c/Users/steve/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/FindBoost.cmake:1472 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:17 (find_package)
CMake Warning at /cygdrive/c/Users/steve/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/FindBoost.cmake:765 (message):
Imported targets not available for Boost version
Call Stack (most recent call first):
/cygdrive/c/Users/steve/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/FindBoost.cmake:869 (_Boost_COMPONENT_DEPENDENCIES)
/cygdrive/c/Users/steve/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/FindBoost.cmake:1472 (_Boost_MISSING_DEPENDENCIES)
CMakeLists.txt:17 (find_package)
CMake Error at /cygdrive/c/Users/steve/.CLion2017.2/system/cygwin_cmake/share/cmake-3.8.2/Modules/FindBoost.cmake:1842 (message):
Unable to find the requested Boost libraries.
Unable to find the Boost header files. Please set BOOST_ROOT to the root
directory containing Boost or BOOST_INCLUDEDIR to the directory containing
Boost's headers.
Call Stack (most recent call first):
CMakeLists.txt:17 (find_package)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
Boost_INCLUDE_DIR (ADVANCED)
used as include directory in directory /cygdrive/c/Users/steve/Dropbox/Projects/cpp-spider
used as include directory in directory /cygdrive/c/Users/steve/Dropbox/Projects/cpp-spider
used as include directory in directory /cygdrive/c/Users/steve/Dropbox/Projects/cpp-spider
-- Configuring incomplete, errors occurred!
See also "/cygdrive/c/Users/steve/Dropbox/Projects/cpp-spider/cmake-build-debug/CMakeFiles/CMakeOutput.log".
make: *** [Makefile:176: cmake_check_build_system] Error 1
How can I diagnose the reason of the problem? Any idea how I can fix it?