CMake to create ActiveX OCX?

Today I played with CMake, and so far it has worked perfectly. Our project consists of projects +100 Visual Studio 2003; we want to upgrade to VS2008 and ultimately VS2010, and also support the makefile build system (and possibly also Eclipse CDT) ... so defining our projects using CMake configuration files and generating project files and make files seems a possible way.

However, we have a large number of OCX, and I could not find any examples of this. Does anyone know about an OCX project with CMake?

Thank! - Josh

+3
source share
3 answers

, , activex cmake. , , activex , , cmake.

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(MyProject)

# Very useful if project has more than one target
SET(BIN_OUTPUT_DIR ${MyProject_BINARY_DIR}/bin)
SET(LIB_OUTPUT_DIR ${MyProject_BINARY_DIR}/lib)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIR})
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${BIN_OUTPUT_DIR})
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIB_OUTPUT_DIR})

ADD_DEFINITIONS("-DWIN32 -D_WINDOWS -D_USRDLL")
ADD_DEFINITIONS("-D_AFXDLL -D_UNICODE -DUNICODE -D_WINDLL")
# Not sure if all this compiler flags are needed, but they reflect the default 
# parameter when creating an activex project
ADD_DEFINITIONS("/Oi /GL /Gy /Z7")
SET(CMAKE_SHARED_LINKER_FLAGS "/OPT:REF /OPT:ICF /MACHINE:X86 /SUBSYSTEM:WINDOWS /LTCG")

# I left this here just as an example it is not needed
FIND_PACKAGE(Boost)

SET(TargetName MyTarget)

FILE(GLOB mytarget_src *.cpp *.idl *.def)
FILE(GLOB mytarget_hdr *.hpp *.h)
FILE(GLOB mytarget_res *.rc *.bmp)
SOURCE_GROUP("Header Files" FILES ${mytarget_hdr})
SOURCE_GROUP("Resource Files" FILES ${mytarget_res})

# I tried to make this work, but I couldn't, so right now my project doesn't use pch's
#ADD_PRECOMPILED_HEADER(${TargetName} stdafx.h stdafx.cpp)

# The last directory is a hack, but it is needed, since the midl compiler outputs the
# tlb file there, which is later needed by the resource compiler
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR}
                    ${CMAKE_CURRENT_BINARY_DIR}/${TargetName}.dir/${CMAKE_CFG_INTDIR})

ADD_LIBRARY(${TargetName} SHARED ${mytarget_src} ${mytarget_hdr} ${mytarget_res})
TARGET_LINK_LIBRARIES(${TargetName}) # It is obvious what you put here

SET_TARGET_PROPERTIES(${TargetName} PROPERTIES SUFFIX ".ocx")
+2

- , .

OCX - DLL , CMake DLL. . , .

+1

FireBreath DLL- ActiveX CMake. , , , OCX. ATL.

Of course, FireBreath does a lot of other things, as it is an environment for creating browser plug-ins, but you can look at the cmake structure and see what we do. The only “difficult” thing I had to solve was that cmake sometimes couldn’t handle .idl files, so instead of adding .idl files, I created my own build steps to handle the midl call.

+1
source

Source: https://habr.com/ru/post/1726864/


All Articles