I am having an LNK2019 build issue with connecting this CMake project to the SIM_CONNECT_LIBRARY. This exact code worked fine in FSX and ESP but doesn’t work on MSFS2020. Regular CPP projects connect fine using the solution properties to link the lib and inc locations, but NOT CMake projects. I am wondering if I am doing something wrong with my CMake or if the SDK for 2020 does not support CMake projects yet?
FindSimConnect.cmake
(I should note that I changed the MSFS2020 SDK dir name from “include” to “inc” since “include” is a cmake keyword)
set(sim_connect_default_path
to_cmake_path(
##"C:\\Program Files (x86)\\Microsoft Games\\Microsoft Flight Simulator X SDK\\SDK\\Core Utilities Kit\\SimConnect SDK"
"C:\\MSFS SDK\\SimConnect SDK"
)
)
find_path(SIM_CONNECT_INCLUDE_DIR
NAMES SimConnect.h
PATHS ${sim_connect_default_path}
PATH_SUFFIXES inc
)
find_library(SIM_CONNECT_LIBRARY
NAMES SimConnect.lib
PATHS ${sim_connect_default_path}
PATH_SUFFIXES lib
)
find_package_handle_standard_args(SimConnect DEFAULT_MSG
SIM_CONNECT_INCLUDE_DIR
SIM_CONNECT_LIBRARY
)
mark_as_advanced(SIM_CONNECT_LIBRARY SIM_CONNECT_INCLUDE_DIR)
CMakeLists.txt
project ("MyTestProject")
......
include_directories(${SIM_CONNECT_INCLUDE_DIR})
......
target_link_libraries(MyTestProject ${SIM_CONNECT_LIBRARY})
I get a LNK2019 on all objects in the SimConnect.lib and one warning (see below).
error LNK2019: unresolved external symbol _SimConnect_CallDispatch@12 referenced in function "void __cdecl testSendEvent(void)" (?testSendEvent@@YAXXZ)
warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'